平滑滚动问题

我使用以下js代码在页面上平滑滚动。 问题是我使用以下JS后无法使用mycarousel的导航。 反正有没有修复我的后续js所以它不会影响我的旋转木马导航。 因为轮播导航上的# (href =“#myCarousel”)而发生此问题。 那么在这种情况下如何解决问题。

 $(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) +']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); }); 

我的轮播导航:

   

替换它

 $('a[href*=#]:not([href=#])').click(function() { 

有:

 $('a[href*=#]:not([href=#media])').click(function () { 

快乐的编码!

这对我有用。 我换了

 $('a[href*=#]:not([href=#])').click(function() { 

 $('a[href*=#]:not([href=#carousel-example-generic])').click(function() { 

其中#carousel-example-generic可以是控件指向的轮播的名称