jquery get search parameter 1

jquery get search parameter

$.urlParam = function (name) {
    var results = new RegExp('[\?&]' + name + '=([^&#]*)')
                      .exec(window.location.search);

    return (results !== null) ? results[1] || 0 : false;
}

console.log($.urlParam('action')); //edit

Here is what the above code is Doing:
1. It’s creating a jQuery function called urlParam.
2. It’s using a regular expression to get the value after the equal sign (=) in the URL.
3. It’s returning the value.

Similar Posts