When I add
<!DOCTYPE html>
to the top of my html file, my linked script.js stops working. However, it works fine without the doctype tag. It should add a class to my nav when i scroll down and remove it when i scroll back up.
Here is my javascript:
var myNav = document.getElementById('header');
window.onscroll = function () {
"use strict";
if (document.body.scrollTop >= 50 ) {
myNav.classList.add("nav-colored");
myNav.classList.remove("nav-transparent");
}
else {
myNav.classList.add("nav-transparent");
myNav.classList.remove("nav-colored");
}
};
Any help is appreciated. Thanks!