Reputation: 5923
I have this dynamic text pluto.co/bf4d4ce3-c2b9-4e77-8adb-925f5adf927a
, I want to remove with jquery the code between slash and the end of text.
I tried with the following:
var div = $("div.text");
div.text(div.text().trim().replace("/bf4d4ce3-c2b9-4e77-8adb-925f5adf927a", ""));
But doesn't work because the text changes when I refresh the page.
Upvotes: 0
Views: 43
Reputation: 27765
You can do this without regex:
var tmpString = div.text().trim().split('/');
tmpString.pop();
div.text(tmpString.join(''));
Upvotes: 1