Answers for "change nav color on scroll vanilla js"

1

javascript on scroll change nav color

$(function () {
  $(document).scroll(function () {
    var $nav = $(".navbar-fixed-top");
    $nav.toggleClass('scrolled', $(this).scrollTop() > $nav.height());
  });
});
Posted by: Guest on July-14-2020
0

change nav color on scroll vanilla js

var myNav = document.getElementById("nav");

window.onscroll = function() {
  "use strict";
  if (document.body.scrollTop >= 280 || document.documentElement.scrollTop >= 280) {
    myNav.classList.add("scroll");
  } else {
    myNav.classList.remove("scroll");
  }
};
Posted by: Guest on May-23-2021
0

change nav color on scroll vanilla js

if (document.body.scrollTop >= 280 || document.documentElement.scrollTop >= 280) {
Posted by: Guest on May-23-2021

Code answers related to "change nav color on scroll vanilla js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language