简体   繁体   中英

want to change nav links color on hover when scroll down to top --jquery

i just want to change the font color on hover when scrollTop() > 10

My CSS

.navbar-default .navbar-nav>li>a:hover, .navbar-default .navbar-nav>li>a:focus {
 color:#fff;
}
.navbar-default.scrolled{
  background-color: #1F1F1F;
}

i wanna make #10d9e4 this links color to be on hover when nav changes it's style

My JS

  var a = $(".navbar-default").offset().top;
  $(document).on('scroll', function() {
   if ($(this).scrollTop() > 10) {
    $('.navbar-default').addClass("scrolled");
   } else {
    $('.navbar-default').removeClass("scrolled");
   }
 });

Add rule for hover when .navbar-default has class 'scrolled', it will redefine default #fff color:

.navbar-default.scrolled .navbar-nav > li > a:hover {
  color: #10d9e4;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM