matwonk matwonk - 4 months ago 9
jQuery Question

Get query string parameters with jQuery

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.

Answer

JQuery jQuery-URL-Parser plugin do the same job, for example to retrieve the value of search query string param, you can use

$.url().param('search');