Reputation: 458
I use this script on html:
$(function () {
$('table.menu a').bind('click', function (event) {
var $anchor = $(this);
//if you don't want to use the easing effects:
$('html, body').stop().animate({
scrollTop: $($anchor.attr('href')).offset().top - 170
}, 1500);
event.preventDefault();
});
});
but I have a problem, on address bar not appears the links name...
my questions is: how can I write my anchor on address bar?
Upvotes: 0
Views: 447
Reputation: 227200
I assume the links are to hashes on the page. Like <a href="#div2">
? In that case, this JavaScript code is un-needed. The browser will auto-scroll you to the element with that ID.
If you want (or for whatever reason need) to use that code, you can set location.hash
, that will update the URL bar.
location.hash = $anchor.attr('href');
Upvotes: 2