[英]scroll anchor show/hide
was working on a anchor point that triggers a divs visibility. 正在触发div可见性的锚点上工作。 There's no problems if I run it with Jquery 1.3.2 library but when I try with 1.7.1 it's not recognized.
如果我使用Jquery 1.3.2库运行它没有问题,但是当我尝试使用1.7.1时,它不会被识别。 any ideas?
有任何想法吗?
$(function() {
var a = function() {
var windowtop = $(window).scrollTop();
var d = $("#anchor").offset({scroll:false}).top;
var c= $("#flyout");
if (windowtop > d) {
c.css({visibility:"visible"});
} else {
if (windowtop <= d) {
c.css({visibility:"hidden"});
}
}
};
$(window).scroll(a);a()
});
});
d
seems to always return undefined
. d
似乎总是返回undefined
。
I suspect your code breaks because of the {scroll:false}
object your are passing as an argument to offset()
. 我怀疑您的代码中断是由于您将
{scroll:false}
对象作为参数传递给offset()
。 Removing it might solve your problem. 删除它可能会解决您的问题。
Check the jQuery().offset() API; 检查jQuery()。offset() API;
jQuery(elem).offset()
returns an object containing the element's top and left coordinates. jQuery(elem).offset()
返回一个包含元素的顶部和左侧坐标的对象。 Can be used as jQuery(elem).offset().top;
可以用作
jQuery(elem).offset().top;
. 。
jQuery(elem).offset({top:20, left:20});
sets the new top and left coordinates for the element. 设置元素的新的顶部和左侧坐标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.