html - Smooth Scrolling JavaScript work on all A tags -


i have following javascript code smoothing scrolling:

$(document).on('click', 'a', function(event){     event.preventdefault();      $('html, body').animate({         scrolltop: $( $.attr(this, 'href') ).offset().top     }, 500); }); 

now can't use other links on website. when this: link nothing happened.

my website: http://www.be-virtual.org/schnittchen

currently targets <a> tag. change selector correctly target start #:

$(document).on('click', 'a[href^="#"]', function(event){     event.preventdefault();      $('html, body').animate({         scrolltop: $( $.attr(this, 'href') ).offset().top     }, 500); }); 

Comments

Popular posts from this blog

ios - Is 'init' forbidden as *part* of a variable name? -

file - Python: AttributeError: 'str' object has no attribute 'readlines' -

c# - Get the Class name in a class with atribute inside a attribute method -