考虑我的网址就像
http://localhost:4588/home?name=test&value=2003&view=current&index=1&....
我需要将 URL 带到“view”查询字符串。
这在 jQuery 中可能吗?
编辑:
url 中的前三个值单独常量(名称、值和 View ),在“ View ”之后它将发生变化。所以我只需要获取“view”查询字符串。
最佳答案
您可以使用split()
分割URL:
var url = "http://localhost:4588/home?name=test&value=2003&view=current&index=1&....";
console.log(url.split('&index')[0])
说明:
url.split('&index')
将返回一个包含 2 个值的 array
:
['http://localhost:4588/home?name=test&value=2003&view=current','=1&....']
,这里你想要的只是第一个值(该值的索引 0 [0])。
更多关于split() .
关于javascript - 获取 url uptp 所需的查询字符串 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46724406/