使用JQ获取URL携带的参数值

版权声明:本文为博主原创文章,未经博主允许不得转载。转载请在文章开头添加出处: https://blog.csdn.net/weixin_38676276/article/details/86594494

 函数: 参数name为字段名

(function ($) {
    $.getUrlParam = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
})(jQuery);

使用:

 type = $.getUrlParam("type");

猜你喜欢

转载自blog.csdn.net/weixin_38676276/article/details/86594494