Answers for "update param in url jquery"

0

update param in url jquery

var url = new URL('http://demourl.com/path?id=100');
var search_params = url.searchParams;

// add "topic" parameter
search_params.set('topic', 'main');

url.search = search_params.toString();

var new_url = url.toString();

// output : http://demourl.com/path?id=100&topic=main
console.log(new_url);
Posted by: Guest on February-09-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language