Fetch QueryString Data Using JQuery

It's very easy to get the QueryString Parameters Value using C# Code Or PHP. But some, including me, are concerned about how to fetch using Jquery. Finally have found the solution, let's see how to do this.
 
There is a simple Script For This Trick
 
Try Your Link With Parameters.
 
Example

http://tirthak/getquerystring.aspx?name=tirthak&id=1 It Will Give you Your Parameter Values
 
[name]=tirthak;
[id]=1
 

<script type="text/javascript">

    $(document).ready(function () {

        var first = getUrlVars()["id"];

        var second = getUrlVars()["page"];

        alert(first);

        alert(second);

    });

    function getUrlVars() {

        var vars = {};

        var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, key, value) {

            vars[key] = value;

        });

        return vars;

    } 

</script>