[英]javascript to give class (1) when scroll to a div and remove class (1) change to class (2) when leave the div?
[英]How to change class when it scroll to end of div?
好的,我有3個div。 我在第二個div中有固定菜單,我希望固定菜單只在第二個菜單中修復,當它從那個div出來時display:none;
這是我的小提琴。 有什么建議嗎?
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');
把它放在滾動事件中:
$(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.