Tayyab Vohra
Tayyab Vohra

Reputation: 1662

How to get the values in url using jQuery

How to get value from url using jquery I am trying to get multiple values in jQuery

this is my url

https://dev.example.com/front-end-pm/?fepaction=newmessage&=deborah-reynolds&Deborah%20Reynolds

var url      =window.location.href; 
var str = decodeURIComponent(url.split('=').pop());

I am getting these values

deborah-reynolds&Deborah Reynolds

now i want to further breakdown like this

deborah-reynolds

Deborah Reynolds

Upvotes: 2

Views: 40

Answers (1)

Pranav C Balan
Pranav C Balan

Reputation: 115212

You just have to split one more time with & separator.

var url = 'https://dev.example.com/front-end-pm/?fepaction=newmessage&=deborah-reynolds&Deborah%20Reynolds'

var str = decodeURIComponent(url.split('=').pop()).split('&');
// here-------------------------------------------^^^^^^^^^^^--

console.log(str[0])
console.log(str[1])

Upvotes: 1

Related Questions