Created
October 13, 2015 23:49
-
-
Save warrendodsworth/8dee86083cca206d0f57 to your computer and use it in GitHub Desktop.
Javascript Query string reader - attached to jQuery namespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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