Get a URL parameter with JQuery [duplicate]

0

Good morning everyone, I have a question. I have this URL: link

How can I get the 22054 parameter from that URL and assign it to a variable in JQuery?

    
asked by anonymous 18.01.2018 / 13:35

1 answer

1

Assuming that the element you want to capture is always in the end of the URL, you can do this:

var url = 'http://localhost/admin-ativo.com/public/evento/edit4/id_menu/8/id_evento/22054'.split('/');

var last = url.pop();

console.log(last); // 22054
    
18.01.2018 / 13:40