Created
November 13, 2019 07:27
-
-
Save fayazara/ffaa9878b25e8e33b7aeb189af754173 to your computer and use it in GitHub Desktop.
Get Query parameter from Current URL using vanilla.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let urlParams = new URLSearchParams(window.location.search.substring(1)); | |
let value = urlParams.get("query"); | |
/* | |
Example URL - https://example.com?name=John | |
console.log(urlParams.get("name")); | |
"John will be printed in log" | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment