[英]Positioning and showing hidden elements with jquery
Trying to implement something similar to qtip, but using a table that compares the features of different things instead, and am running into an issue positioning the hidden elements I want to show on mouseover. 试图实现类似于qtip的方法,但是使用了一个比较不同事物功能的表,并且遇到了一个问题,即我想在鼠标悬停时显示的隐藏元素的位置。 Any help would be much appreciated. 任何帮助将非常感激。 http://jsfiddle.net/2HMjQ/ http://jsfiddle.net/2HMjQ/
Instead of event.pageY
, I tried to use $(this).position().top
and an offset of 50 to position is right below the link. 我尝试使用$(this).position().top
而不是event.pageY
,并且位置的偏移量50在链接的正下方。 See below, 见下文,
content.on('mouseenter',function(){ //Used .on instead of bind
var index=content.index(this);
if(index<0){
stop();
}
else{
content.eq(index).css("font-weight","bold");
display.stop(true,true);
display.eq(index).css("top",+ $(this).position().top + 50); //Changed
display.eq(index).fadeIn('slow');
}
}).on('mouseleave',function(){ //Used .on instead of bind
var index=content.index(this);
display.hide();
content.css("font-weight","normal");
});
DEMO: http://jsfiddle.net/2HMjQ/13/ 演示: http : //jsfiddle.net/2HMjQ/13/
display.eq(index).css("top",+event.PageY);
needs to be: 需要是:
display.eq(index).css("top",+event.pageY);
- notice the lowercase 'p'. -注意小写的“ p”。
It looks like there's a simple problem with case. 看来情况很简单。 event.PageY should be event.pageY. event.PageY应该是event.pageY。
I've fixed this and made some minor CSS changes tinkering around with your code here: http://jsfiddle.net/2HMjQ/11/ 我已修复此问题,并在此处对您的代码进行了一些小的CSS更改: http : //jsfiddle.net/2HMjQ/11/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.