如何使用jQuery从字符串中提取URL参数 [英] How to use jQuery to extract a URL parameter from a string

查看:513
本文介绍了如何使用jQuery从字符串中提取URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我完成了一项任务,并且知道我必须继续,但是对regexp的体验很糟糕... :(

i hat one task, and know i have to continue but have a bad experience with regexp ... :(

有人可以帮助我吗?

我需要使用jquery从域名url"中获取帮助:

i need to take a sting from "domain url" with jquery :

这是地址名称:

http://mydomain/Our-Company/default.aspx?txt=James D. Perrlo

我想在?txt =之后加上jquery la字符串,在这种情况下是"James D. Perrlo"

I want to take with jquery la string after "?txt=" in this case "James D. Perrlo"

PS:此字符串始终是网址的结尾

PS: This string always is ends of the url

有人可以帮助我吗?

谢谢!

推荐答案

这个小 URL插件可让您执行以下操作:

This small URL plugin lets you do this:

var url = $.url('http://allmarkedup.com/folder/dir/index.html?item=value');
url.attr('protocol'); // returns 'http'
url.attr('path'); // returns '/folder/dir/index.html'

https://github.com/allmarkedup/jQuery-URL-Parser

这篇关于如何使用jQuery从字符串中提取URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆