Skip to content

Instantly share code, notes, and snippets.

@warrendodsworth
Created October 13, 2015 23:49
Show Gist options
  • Select an option

  • Save warrendodsworth/8dee86083cca206d0f57 to your computer and use it in GitHub Desktop.

Select an option

Save warrendodsworth/8dee86083cca206d0f57 to your computer and use it in GitHub Desktop.
Javascript Query string reader - attached to jQuery namespace
//Query string reader function attacehd to jQuery namespace
$.qs = function ( name ) {
name = name.replace( /[\[]/, "\\[" ).replace( /[\]]/, "\\]" );
var regex = new RegExp( "[\\?&]" + name + "=([^&#]*)" );
var results = regex.exec( location.search );
return results == null ? '' : decodeURIComponent( results[1].replace( /\+/g, " " ) );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment