i have a url like this. http://localhost:8080/steer/trip/create/3. where in my page i want to get value \"3\" using the jquery . please help me
Here is a easy to read and understand JS function that you can use to retrieve any variable from url.
All you need to do is call this function with name of the variable that you want to filter and it will return the value back to you.
Hope it helps:
function getVarFromURL(varName){
var url = window.location.href;
url = url.substring(url.indexOf('?'));
var urlLowerCase = url.toLowerCase();
varName = varName.toLowerCase();
if (urlLowerCase.indexOf(varName + "=") != -1) {
var value = url.substring(urlLowerCase.indexOf(varName) + varName.length + 1);
if (value.indexOf('&') != -1) {
value = value.substring(0, value.indexOf('&'));
}
return value;
}
else {
return null;
}
}