Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
in Web Development by 35 40 48
recategorized by

I need to get the query string value from the current URL using JQuery or Javascript,

For example, the current page URL is


the expected value should be 1, What's the best way to get query string value from URL in JQuery or Javascript without using custom function?

1 Answer

1 like 0 dislike
by 2 2 9
selected by
Best answer

How to get URL parameters Value in JavaScript?

The below code would help to get URL parameters Value from URL using JavaScript instead of JQuery:

var QueryString = (new URL(location.href)).searchParams.get('id');
by 35 40 48
0 0
It's the simplest way I have ever seen, Thank you!
If you don’t ask, the answer is always NO!