gpt4 book ai didi

javascript - 使用 jQuery 从 URL 获取一部分

转载 作者:行者123 更新时间:2023-11-28 15:08:24 24 4
gpt4 key购买 nike

我怎样才能得到“?”之前的部分?使用 jQuery 生成 URL?

例如,我有以下 URL:
http://example/group/abc/?author=gfg&city=gfg

我想得到这个:
http://example/group/abc/

<小时/>

如果网址是这样的:
http://example/group/abc/xyz?author=gfg&city=gfg

我想获取这个网址:
http://example/group/abc/xyz

最佳答案

不需要 jQuery。
window.location.href.split('?')[0]

关于javascript - 使用 jQuery 从 URL 获取一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37841104/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com