my link is www.example.com/#about
I want to hide #about
from url. I have created a html page when I click about
then scroll should go at about section on same page.but #about
show in url. I want to hide #about
. #etc
my page working same but hide id after (#etc) only want example.com not want a www.example.com/#etc
.
Please find the link to a fiddle I have created. Hope this helps :)
JS File
$(document).ready(function() {
$('a').on("click", function(e) {
var scrollTo = e.toElement.text
console.log($(this).text())
var posTop = $("#" + scrollTo).offset().top;
console.log(posTop);
e.preventDefault();
e.stopPropagation();
$('html, body').scrollTop(posTop);
console.log(window.location);
});
})
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.