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

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -