开发者

jQuery and RegEx to extract a bit of information from URL Querystring

开发者 https://www.devze.com 2023-02-04 02:14 出处:网络
The query strings in my ASP.NET MVC are formatted like this: http://mysite.com/blog/tag/my-tag, instead of http://mysite.com/blog/?tag=my-tag, I need to extract the \"my-tag\" bit out of 开发者_开发问

The query strings in my ASP.NET MVC are formatted like this: http://mysite.com/blog/tag/my-tag, instead of http://mysite.com/blog/?tag=my-tag, I need to extract the "my-tag" bit out of 开发者_开发问答the URL, how could I accomplish that with jQuery on document loaded?


No need to use jQuery for that:

var tag = window.location.href.split('/').pop();


Try This:

document.location.toString().match('.*/(.*)$')[1]
0

精彩评论

暂无评论...
验证码 换一张
取 消