带有jQuery参数的路径名

时间:2015-01-10 07:22:00

标签: javascript jquery

我有一个链接

喜欢:

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);

        });

现在我得到了这个

测试

有人对此有所了解

谢谢

2 个答案:

答案 0 :(得分:1)

这个怎么样?

jQuery(document).ready(function() {    
    alert(window.location.pathname + location.hash);
});

答案 1 :(得分:0)

测试是路径,#test是锚点,也是网址查询的一部分。

相关问题