How to remove last params from the url for instance, i have url such as
http://localhost/autoservice/public_html/tickets/load_service/6
i want to get this result
http://localhost/autoservice/public_html/tickets
how to make this with jquery or javascript
i have tried many solutions by reading many post on stack but i can't get it right
var url = $(location).attr('href');
Try this simple method using lastIndexOf()
and slice()
url = 'http://localhost/autoservice/public_html/tickets/load_service/6';
url = url.slice(0, url.lastIndexOf('/'));
url = url.slice(0, url.lastIndexOf('/'));
alert(url);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With