Home > Web Front-end > JS Tutorial > body text

jQuery 获取URL的GET参数值的小例子_jquery

WBOY
Release: 2016-05-16 17:36:25
Original
994 people have browsed it
复制代码 代码如下:

// * jQuery url get parameters function [获取URL的GET参数值]
// *character_set UTF-8
// * author Jerry.li(lijian@dzs.mobi)
// * version 1.2012.12.11.1400
// *  Example
// *     <br>// *      var GET = $.urlGet(); //获取URL的Get参数<br>// *      var id = GET['id']; //取得id的值<br>// *    
(function($)
{
    $.extend(
    {
//       
//          url get parameters
//          public
//         return array()
//      
        urlGet:function()
        {
            var aQuery = window.location.href.split("?");//取得Get参数
            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("=");//分离key与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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!