a plugin that extends jquery to easily access querystring params.
JavaScript HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
jquery.querystring.js added a function that parses the querystring and returns it as a JSON… Oct 11, 2015



@author gehsekky

code taken from here

it should be noted that the $.querystring function ALWAYS returns a string. the following should illustrate:

  • querystring param exists and has value: that value
  • querystring param exists and doesn't have value: empty string
  • querystring param does not exist: empty string
  • param given is empty string: empty string

also, as stated in the above stackoverflow answer, this solution doesn't handle multi-value keys (eg. ?key1=aa&key2=bb&key1=bb) as it just grabs the last one.


var qvalue = $.querystring("q");

$.querystringToJSON should always return an object with keys and values. This function DOES handle multi-value keys by packing them into an array.


// https://www.example.com?key1=aa&key2=bb&key1=bb
var qobject = $.querystringToJSON();
alert(qobject.key1[1]) // result: bb