I canโt find anything about it on Google or here.
I have a div in it, some text and some html as such:
<div id="test-div"> http://<strong>somewebsite.com</strong>/big/long/unfriendly/path/ </div>
What I want to do is add <wbr> after each slash. (Because the value does not wrap otherwise and ruin my table). Doing a simple replacement with $('#test-div').html() would also be useless with a strong tag, so this is not an option.
I decided to use $('#test-div').contents() to filter the text parts (recursively). However, I cannot edit individual bits. I would expect this to change http: // part:
$('#test-div').contents().first().text("something");
However, he does nothing. I know that I have the right to navigate because something like this:
$('#test-div').contents().first().wrap( "<b></b>" );
works.
Why can't I change the text bit? (A more elegant solution to the original problem will also be great)
source share