1
sir我想鎖定我的菜單與div ID menu
固定在窗口頂部向下滾動窗口時,我也想設置位置爲絕對向上滾動時I嘗試使用此代碼。它正確地完成了第一份工作。我可以將菜單固定在頁面頂部。但它不能設置在此處向上滾動頁面的絕對位置是我的代碼向下滾動固定div&向上滾動時設置絕對
<script type="application/javascript">
$(window).bind('scroll', function() {
if (window.scrollY=100){
document.getElementById("menu").style.position = "fixed";
document.getElementById("menu").style.top = "0px";
}
else if(window.scrollY < 100){
document.getElementById("menu").style.position = "absolute";
document.getElementById("menu").style.top = "100px";
}
});
</script>