[英]Positioning and showing hidden elements with jquery
試圖實現類似於qtip的方法,但是使用了一個比較不同事物功能的表,並且遇到了一個問題,即我想在鼠標懸停時顯示的隱藏元素的位置。 任何幫助將非常感激。 http://jsfiddle.net/2HMjQ/
我嘗試使用$(this).position().top
而不是event.pageY
,並且位置的偏移量50在鏈接的正下方。 見下文,
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");
});
演示: http : //jsfiddle.net/2HMjQ/13/
display.eq(index).css("top",+event.PageY);
需要是:
display.eq(index).css("top",+event.pageY);
-注意小寫的“ p”。
看來情況很簡單。 event.PageY應該是event.pageY。
我已修復此問題,並在此處對您的代碼進行了一些小的CSS更改: http : //jsfiddle.net/2HMjQ/11/
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.