Reputation:
I'm using version 1.4.13 of the plugin, I've also made sure that the page has loaded the plugin successfully.
It used to work fine on my website but now it appears to be doing nothing. I am using the following code to run it:
HTML:
<span class="button-project-info">
<a class="button button-04" href="#project-info">Project Info</a>
</span>
CSS:
$('.button-project-info a').bind('click', function(e) {
try {
e.preventDefault();
target = this.hash;
$('html, body').scrollTo(target, 150);
} catch (error) {
alert('error - ' + error);
}
});
I've also tried the following, and the alert
statement runs fine when the link is clicked:
$('.button-project-info a').bind('click', function(e) {
alert('0000');
});
Upvotes: 0
Views: 197
Reputation: 251262
If you want to scroll the whole page, use:
target = this.hash;
$(window).scrollTo(target, 150);
I tend to use the href
from the anchor when I do this, so instead of target = this.hash;
I grab the hash from the link.
Here is my preferred implementation, which basically catches all hash-URLs and scrolls...
$('.button-project-info a').click(function () {
var hash = '#' + this.href.split('#')[1];
$(window).scrollTo(hash, 1000);
return false;
});
Upvotes: 1