我正在使用此代码,但它并不像我期望的那样工作。
$("#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");
})
});
主要问题是:
$("#myNavbar").on("activate.bs.scrollspy", function(){
}
滚动页面时会激活jQuery。如何在li
元素出现时向其中添加一个类?
答案 0 :(得分:0)
使用此代码
$('body').scrollspy({ target: '#navbar-example' });
用导航栏替换导航栏示例 阅读文档:http://getbootstrap.com/javascript/#scrollspy