Catherinepan (Talk | contribs) |
Catherinepan (Talk | contribs) |
||
Line 67: | Line 67: | ||
window.onscroll = function() {myFunction()}; | window.onscroll = function() {myFunction()}; | ||
− | var | + | var dropdown = document.getElementById("dropdown"); |
− | var sticky = | + | var sticky = dropdown.offsetTop; |
function myFunction() { | function myFunction() { | ||
if (window.pageYOffset >= sticky) { | if (window.pageYOffset >= sticky) { | ||
− | + | dropdown.classList.add("sticky") | |
} else { | } else { | ||
− | + | dropdown.classList.remove("sticky"); | |
} | } | ||
} | } |
Revision as of 04:48, 20 August 2018