페이지 하단 (position:absolute;bottom:0px;
)에 메뉴로드를 고정하려고하지만 사용자가 스크롤하면 상단에 고정 (position:fixed;top:0px;
)하고 싶습니다.jQuery scroll then fixed
여기 내 jQuery를 수 있습니다 :
var main = function(){
var menu = $('#menu')
$(document).scroll(function(){
if ($(this).scrollTop() >= $(window).height() - menu.height()){
menu.removeclass('bottom').addclass('top')
} else {
menu.removeclass('top').addclass('bottom')
}
})
}
$(document).ready(main);
을 그리고 여기 내 JSFiddle
내가 성공적으로 상위 클래스를 추가 할 수 못하고있다.
아이디어가 있으십니까? 고맙습니다!
'removeClass' 및'addClass'를 사용해보세요. 대문자 사용이 중요합니다. – Stryner
@ 변경 사항 만 변경되었지만 클래스는 계속 추가되지 않습니다. – starvator
그리고 jQuery를 임베딩하는 것을 잊지 마십시오. – YMMD