Remove hashtag(#) from url

被刻印的时光 ゝ 提交于 2019-11-28 14:04:30

You could try that:

$(window).on('hashchange', function(e){
    history.replaceState ("", document.title, e.originalEvent.oldURL);
});
Honorable Chow

first add a class to your a tag that you want this behavior for, or a html 5 data- attribute. Then your link becomes;

<a href="#btnq1" class="remove-hash"><button>Button</button></a>

$('body').on('click', ".remove-hash", function(e){
    $(this).removeAttr('href');
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!