Check out this code snippet:
var moving_nav = document.getElementById("moving_nav");
var logo = document.getElementById("logo");
setInterval(function(){
var scrolled = window.pageYOffset || document.documentElement.scrollTop;
if (scrolled >= 100) {
moving_nav.style.position = "fixed";
moving_nav.style.top = "0";
logo.style.width:"60px";
logo.style.height:"60px";
}
else {
moving_nav.style.position = "absolute";
moving_nav.style.top = "100px";
logo.style.width:"120px";
logo.style.height:"120px";
}
}, 10);
The intention was to make the menu sticky when scrolling over it. The functionality worked perfectly fine :). However, encountered an issue when trying to change the logo size. After including the lines involving the "logo", the script stopped working properly.
The Browser Console indicates a missing ";" in line 9 (first "width"), but pinpointing its exact location has proven challenging. Attempted to resolve by eliminating the use of a variable and querying getElementById each time, without success. Also experimented with commenting out the logo styling lines, which allowed everything else to function correctly. Unable to identify the root cause :( Please assist!
PS: If you find this problem too simple, please bear in mind that I am new to JavaScript. Additionally, English is not my first language so apologies for any linguistic errors ;)
Thank you, Diavo