Retrieve QueryString Parameter Value using jQuery

To Retrieve query string parameter using jQuery use below code

<script language="javascript" type="text/javascript">
/* ----------- Get QueryString Parameter Code Starts -------------*/
function getParameterByName(name, url) {

        if (!url) url = window.location.href;
        name = name.replace(/[\[\]]/g, "\\$&");
        var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
            results = regex.exec(url);
        if (!results) return null;
        if (!results[2]) return '';
        return decodeURIComponent(results[2].replace(/\+/g, " "));

 }
/* ----------- Get QueryString Parameter Code End -------------*/
</script>

Use above function to get Parameter Value

<script language="javascript" type="text/javascript">
$(document).ready(function() {
    var para = getParameterByName('EmpID');
});
</script>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s