Skip to content

Instantly share code, notes, and snippets.

@wdmtech
Last active August 29, 2015 14:21
Show Gist options
  • Save wdmtech/91f908121f6d4082212e to your computer and use it in GitHub Desktop.
Save wdmtech/91f908121f6d4082212e to your computer and use it in GitHub Desktop.
Gets query string parameters in jQuery
// Gets query string parameters
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
if(results && results.length > 0) {
return results[1] || 0;
}
};
// Example usage
if($.urlParam('screen_grab'))
{
// trigger click on .thing
$('.thing').trigger('click');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment