javascript - How can I add a class to the active menu item using bootstrap scrollspy? -
i'm using code, doesn't work expecting.
$("#mynavbar").on("activate.bs.scrollspy", function(){ $(this).parent('li').addclass('hvr-overline-reveal'); var currentitem = $(".nav li.active > a"); currentitem.parent("li").addclass("hvr-pulse"); currentitem.addclass("hvr-overline-reveal"); }) });
the main issue this:
$("#mynavbar").on("activate.bs.scrollspy", function(){ }
it activates jquery when scroll page. how can add class li
element when occurs?
use code
$('body').scrollspy({ target: '#navbar-example' });
replace navbar example navbar read documentation : http://getbootstrap.com/javascript/#scrollspy
Comments
Post a Comment