jquery 将内容锚定到某个点
我的网站上有一个链接列表,当用户单击一个链接时,我会显示一个带有一些其他选项的工具栏,这些链接显示为 90x60 图像,我希望显示的工具提示将其自身锚定在顶部已单击的链接/图像的左角如何实现此目的,下面是我当前的实现。
$('#wrapper #content ul li a').click(function(e) {
e.preventDefault();
$('#tooltip').remove();
var url = $(this).attr('href');
$.ajax({
type: "POST",
url: url,
data: "",
success: function(html){
var popup = html;
$('#content').append(popup);
$('#tooltip').css({
position: "absolute",
top: e.pageY - 200,
left: e.pageX - 10
});
}
});
});
任何帮助将不胜感激。
I have a a list of links on my website, that when then user clicks on one then I display a toolip with some futher options, the links are display as 90x60 image, I am wanting the tooltip that is display to anchor itself on to the top left hand corner of the link/image that has been clicked how can achieve this, below is my current implementation.
$('#wrapper #content ul li a').click(function(e) {
e.preventDefault();
$('#tooltip').remove();
var url = $(this).attr('href');
$.ajax({
type: "POST",
url: url,
data: "",
success: function(html){
var popup = html;
$('#content').append(popup);
$('#tooltip').css({
position: "absolute",
top: e.pageY - 200,
left: e.pageX - 10
});
}
});
});
Any help would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已经有 jquery 插件了: http://bassistance.de/jquery-plugins/ jquery-plugin-tooltip/
还有更多http:// visionwidget.com/inspiration/web/495-jquery-tooltip-plugins.html
或者您可以编写一些简单的 jQ 脚本:
(HTML)
(JS)
(CSS)
There is jquery plugin for that already: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/
There are more http://visionwidget.com/inspiration/web/495-jquery-tooltip-plugins.html
Or you could just write some easy jQ script:
(HTML)
(JS)
(CSS)
使用 qTip。
更新:这是我的JsFiddle
Use qTip.
Update : Here is my JsFiddle