IamCalvinBrown.com a Blog Site

Code Examples, Consulting Advice and lots of other cool things

Get a Querystring parameter in JQuery

 

var customerId = getParamByName('id');

 console.log("ID: " + customerId ); // write out the value

  function getParamByName(param) {

          paramparam.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");

          var regex = new RegExp("[\\?&]" + param+ "=([^&#]*)"),

          results = regex.exec(location.search);

          return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));

}

Loading