I have a string which is as below :
Documents for 047-428583 > FOLDER A > FOLDER D
I want to remove > FOLDER D while doing a particular operation.
I have tried using substring which is as below but it removes everything after >
var data = $("#extend").text();
$("#extend").text(data.substring(0, data.indexOf('>')));
I have gone through this but in my case i have multiple same characters so i can not use that. I guess!
Use lastIndexOf instead:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf
$("#extend").text(data.substring(0, data.lastIndexOf('>') - 1));
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