sat*_*sat 12 javascript jquery
我正在搞乱一些试图抓住它的jquery.
我有一个绝对位置设置的ul导航,但在我向下滚动200个像素后,我希望切换到固定的位置,以便导航始终保持在页面上.
我该怎么做?
下面是我正在研究的例子
sat*_*sat 13
感谢大家的帮助
这就是我想要的
$(document).ready(function() {
var theLoc = $('ul').position().top;
$(window).scroll(function() {
if(theLoc >= $(window).scrollTop()) {
if($('ul').hasClass('fixed')) {
$('ul').removeClass('fixed');
}
} else {
if(!$('ul').hasClass('fixed')) {
$('ul').addClass('fixed');
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
我从中得到了它
Thankss !!!!!
| 归档时间: |
|
| 查看次数: |
21979 次 |
| 最近记录: |