使用jQuery从URL获取一部分

时间:2016-06-15 16:37:57

标签: javascript jquery

我怎么能在“?”之前得到这个部分?使用jQuery的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

1 个答案:

答案 0 :(得分:4)

没有jQuery必要。
window.location.href.split('?')[0]

相关问题