[英]How to change class when it scroll to end of div?
Ok i have 3 divs. 好的,我有3个div。 I have fixed menu in second div and i want that fixed menu is only fixed in that second menu and when it come out of that div it is display:none;
我在第二个div中有固定菜单,我希望固定菜单只在第二个菜单中修复,当它从那个div出来时display:none;
This is my fiddle. 这是我的小提琴。 Any suggestion? 有什么建议吗?
https://jsfiddle.net/wx38rz5L/1817/ https://jsfiddle.net/wx38rz5L/1817/
if ($(this).scrollTop()>=$('.compare-wrapper').position().top)
$('.compare-menu-fixed').css('display','block');
else
$('.compare-menu-fixed').css('display','block');
Put it inside scroll event: 把它放在滚动事件中:
$(document).on( 'scroll', function(){
if($(this).scrollTop()>=$('.compare-wrapper').position().top)
$('.compare-menu-fixed').css('display','block');
else
$('.compare-menu-fixed').css('display','none');
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.