I'm using the following javascript to perform adding a "sticky" class to "features-menu" div after scrolling down on browser certain amount.
Through search a while ago, I came across this code from another user I believe from stackoverflow, but cannot find that post to reference it. But I was looking for an example that does not use jQuery.
The following works great in Firefox, Chrome, and MS Edge browser but on IE11, the class doesn't seem to get added to the div.
Can anyone kindly suggest a fix for IE without using jQuery? Thank you so much!
<script type = "text/javascript" >
myID = document.getElementById("features-menu");
var myScrollFunc = function() {
var y = window.scrollY;
if (y >= 400) {
myID.className = "sticky"
} else {
myID.className = ""
}
};
window.addEventListener("scroll", myScrollFunc);
</script>