更改链接上的url哈希值

时间:2012-04-05 09:23:03

标签: jquery ajax jquery-bbq

我有一个url字符串,我想知道如何在页面上使用链接时将order = desc部分更改为order = asc?

http://localhost/en/search?city=Paris#order=desc

当我点击链接时,例如

<a href="#">Change order</a>

网址将变为

http://localhost/en/search?city=Paris#order=asc

1 个答案:

答案 0 :(得分:2)

只需在链接(href属性)中包含片段标识符(#之后的部分)。

<a href="#order=asc">Change order</a>