Home > Web Front-end > JS Tutorial > jQuery encapsulated Get parameter example in Url_jquery

jQuery encapsulated Get parameter example in Url_jquery

WBOY
Release: 2016-05-16 17:12:14
Original
1079 people have browsed it

When using pure front-end processing with js, you will encounter the problem of passing the parameters of one web page to the next page through the get method.

At this time, you can use js to get the parameters in the url of the current page. get parameter. The core statement is:

window.location.href

The detailed code will not be explained, there are comments, you can understand it after reading it. It is packaged into a jQuery expansion package.

Copy code The code is as follows:

(function($){
$.extend({
/**
* url get parameters
* @public
* @return array()
*/
urlGet:function()
{
var aQuery = window.location.href.split("?");//Get the Get parameters
var aGET = new Array();
if(aQuery.length > 1)
{
var aBuf = aQuery[1].split("&");
for(var i=0, iLoop = aBuf.length; i{
var aTmp = aBuf[i].split("=");//Separate key and Value
aGET[aTmp[0]] = aTmp[1];
}
}
return aGET;
},
});
})(jQuery);
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template