Skip to content

Instantly share code, notes, and snippets.

@olimortimer
Created July 2, 2012 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olimortimer/3032672 to your computer and use it in GitHub Desktop.
Save olimortimer/3032672 to your computer and use it in GitHub Desktop.
JS: jQuery Replace HREF Query String
// www.website.com/page?id=100
$('#pageLink').attr('href', $('#pageLink').attr('href').replace(/((\?|&)id\=)[0-9]*/, '$1' + '123'));
// www.website.com/page?id=123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment