我在网页中遇到了链接问题。这是我在网页中使用的jQuery代码的一部分:
$.fn.stopAtTop= function () {
var $this = this,
$window = $(window),
thisPos = $this.offset().top,
//thisPreservedTop = $this.css("top"),
setPosition,
under,
over;
under = function(){
if ($window.scrollTop() < thisPos) {
$this.css({
position: 'absolute',
top: ""
});
setPosition = over;
}
};
over = function(){
if (!($window.scrollTop() < thisPos)){
$this.css({
position: 'fixed',
top: 0
});
setPosition = under;
}
};
setPosition = over;
$window.resize(function()
{
bumperPos = pos.offset().top;
thisHeight = $this.outerHeight();
setPosition();
});
$window.scroll(function(){setPosition();});
setPosition();
};
这是一个示例 演示
当我向下滚动时,一切都很好,但当我想回到页面顶部时,却做不到。我知道问题在于脚本使div
固定,但我不知道如何解决它。有什么想法吗?
#four
,这是有意为之吗? - Ben Aubin