Let's say you have the following URL, (www.domain.com/page.php#_number).
I want to extract the id from the url**(_1)** and scroll to it on page load.
Your help will be appreciated.
Thanks for your help all.
The answer:-
$(document).ready(function() {
var $root = $('html, body');
var ancloc = window.location.hash;
event.preventDefault();
$root.animate({
scrollTop: $(ancloc).offset().top
}, 500, function () {
window.location.hash = href;
});
return false;
});
Why not just use an anchor <a href="http://www.domain.com/page.php#number"> and animate that.
Check this link:
Smooth scrolling when clicking an anchor link
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With