I have url like :
http://localhost/index/2/99
through jquery or javascript i want to get the id 2 how can i get this value
i used like:
var url=document.URL;
alert(url.match(/\d+/));
output is:8000
I have url like :
http://localhost/index/2/99
through jquery or javascript i want to get the id 2 how can i get this value
i used like:
var url=document.URL;
alert(url.match(/\d+/));
output is:8000
you can get the url path and get the value by index.
var url = window.location.href.split('/');
console.log(url[3]);
You can get value by using index. url.match(/\d+/) gives you an array You can get it by index position like following:
var url = "http://localhost/index/2/99";
var value = url.match(/\d+/);
console.log(value[0]);