Get query string parameters url values with jQuery / Javascript (querystring)

Anyone know of a good way to write a jQuery extension to handle query string parameters? I basically want to extend the jQuery magic ($) function so I can do something like this:

$('?search').val(); 

Which would give me the value “test” in the following URL: http://www.example.com/index.php?search=test.

I’ve seen a lot of functions that can do this in jQuery and Javascript, but I actually want to extend jQuery to work exactly as it is shown above. I’m not looking for a jQuery plugin, I’m looking for an extension to the jQuery method.

Leave a Comment