我有一个使用我的div ID滚动到特定锚点的滚动插件,
它正在创建如下网址: http://example.com/#examplediv|700
我想找到一种使用js或其他建议的方法来隐藏网址中的哈希值的方法
我想将thishttp://example.com/#examplediv|700
转换为:http://example.com/
有任何想法吗?
您可以修改正在使用的滚动插件,也可以将其自己添加到侧面,但是您将需要执行以下操作:
假设:您与此滚动有关的所有DIV都需要具有anchor-scrolls
该类。
的HTML
<a href="#anchor-hash" class="anchor-scrolls">foo</a>
JS
//using jQuery
(function($){
$('.anchor-scrolls').on('click', function(evt){
evt.preventDefault(); //prevents hash from being append to the url
});
)(window.jQuery);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句