I have a problem in a one page scrolling template that used a plugin (smoothscroll.js) I try to remove hash from url after user click on link but unfortunately I cant do it. I follow this type of question on stackoverflow but not working for me.
My code is below:
index:
<li><a href="#meet-us" class="page-scroll">Meet Us</a></li>
JS:
$('a.page-scroll').click(function (event) {
event.preventDefault();
if(history.pushState) {
history.pushState(null, null, $(this).attr('href'));
}
return false;
});
How to remove just #
. now url localhost/main/#meet-us
but I need localhost/main/meet-us
this type of.
Big appreciated if help anyone.
您可以使用String.prototype.replace :
history.pushState(null, null, $(this).attr('href').replace("#", ""));
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.