jquery change query string parameter value
var currentUrl = 'http://www.example.com/hello.png?w=100&h=100&bg=white'; var url = new URL(currentUrl); url.searchParams.set("w", "200"); // setting your param var newUrl = url.href; console.log(newUrl);
Here is what the above code is Doing:
1. Create a new URL object from the current URL.
2. Set the new value for the w parameter.
3. Get the new URL.