我有一个链接
喜欢:
www.localhost.com/test/#test1
我想要这个输出
test/#test1 using jquery
这是我的代码
jQuery(document).ready(function() {
// my code which is working fine
jQuery(this).attr('href','test/#test1');
alert(window.location.pathname);
});
现在我得到了这个
测试
有人对此有所了解
谢谢
答案 0 :(得分:1)
这个怎么样?
jQuery(document).ready(function() {
alert(window.location.pathname + location.hash);
});
答案 1 :(得分:0)
测试是路径,#test是锚点,也是网址查询的一部分。