Last active
August 17, 2020 02:28
-
-
Save jw-12138/d1ed7cda55e1916cc150f987204f7bda to your computer and use it in GitHub Desktop.
get url parameters using 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 getParam = (p) => { | |
let obj = {} | |
let param = window.location.search.split('?') | |
param = param[1] | |
if(!param) return false | |
param.split('&').forEach(el => { | |
let element_arr = el.split('=') | |
obj[element_arr[0]] = element_arr[1] | |
}); | |
return obj[p] ? obj[p] : false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment