Reputation: 1143
please see this fiddle http://jsfiddle.net/rabelais/Lsbnyntg/1/
When the user clicks on one of the essay links the page should scroll to the top of the essay. However there is no scrolling motion happening, it just quickly jumps to the div. I have tried playing with the animation time but it does not seem to effect it. How can I make the scrolling visible?
$('ul.inner-li-texts li a').on('click', function(event) {
var target = $(this.href);
if ( target.length ) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
} 0, 10000);
}
});
Upvotes: 0
Views: 153
Reputation: 10372
You first selector is incorrect:
$('ul.inner-li-texts li a')
should be
$('#inner-li-texts li a')
You have a typo in your animate statement.
Your target
code does not work, it should look something like this:
$('#inner-li-texts li a').on('click', function(event) {
var target = $($(this).attr('href'));
if ( target.length ) {
event.preventDefault();
$('html, body').animate({
scrollTop: target.offset().top
}, 10000);
}
});
Upvotes: 2