Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrandellWS/d5e7fca862f7d035ab67c2c2cc45407e to your computer and use it in GitHub Desktop.
Save CrandellWS/d5e7fca862f7d035ab67c2c2cc45407e 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