Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get, set, modify url parameters in a query string with JavaScript.
// Get the queryString module from:
// https://github.com/sindresorhus/query-string
console.log(location.href);
// http://sindresorhus.com/?foo=bar
console.log(location.search);
// ?foo=bar
var parsed = queryString.parse(location.search);
console.log(parsed);
// {foo: 'bar'}
parsed.foo = 'unicorn';
parsed.ilike = 'pizza';
location.search = queryString.stringify(parsed);
console.log(location.search);
// ?foo=unicorn&ilike=pizza
@AhsanSN

This comment has been minimized.

Copy link

AhsanSN commented May 12, 2018

a test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.