javascript - Left and Right Carousel Controls not Working when Smooth Scroll for Anchor Tags Used -


i using following script smooth scroll effect anchor tags:

$(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;       }     }   }); }); 

after using script left , right controls bootstrap carousel stopped working.

<a class="left carousel-control" href="#home-carousel" role="button" data-slide="prev">                 <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>                 <span class="sr-only">previous</span>             </a>             <a class="right carousel-control" href="#home-carousel" role="button" data-slide="next">                 <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>                 <span class="sr-only">next</span>             </a> 

how fix this?

then have edit code smooth scroll this, depending if have id header-menu or class header-menu

change

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

to (if use id header-menu)

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

or (if use class header-menu):

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

this way focus smooth scroll effect on menu href elements, , script not "collide" bootstrap hrefs.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -