jQuery查询字符串 [英] jQuery querystring
本文介绍了jQuery查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
使用jQuery获取查询字符串
如何获取a的值使用jQuery查询文本框?
How do I get the value of a querystring into a textbox using jQuery?
让我们说网址是 http://intranet/page1.php?q =你好
我希望你好在文本框中。
I would like the "hello" to be in the textbox.
推荐答案
function querystring(key) {
var re=new RegExp('(?:\\?|&)'+key+'=(.*?)(?=&|$)','gi');
var r=[], m;
while ((m=re.exec(document.location.search)) != null) r.push(m[1]);
return r;
}
您可以使用它来获取查询字符串值并放入文本框中:
You can use that to get the query string value and put in a textbox:
$('#SomeTextbox').val(querystring('q'));
这篇关于jQuery查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文