Select part of text in a tag
- by atlantis
The DOM structure looks like this (existing website ... cant modify it):
<table>
<tr><td>
<br><hr size="1"><strong>some heading 1</strong><br>
<br>some text 1<br>
<br><hr size="1"><strong>some heading 2</strong><br>
<br>some text 2<br>
</td></tr>
</table>
I want to manipulate it so that it looks like this
<table>
<tr><td>
<br><hr size="1"><strong>some heading 1</strong><br>
<br>some text 1<br>
</td></tr>
<tr><td>
<br><hr size="1"><strong>some heading 2</strong><br>
<br>some text 2<br>
</td></tr>
</table>
Using the solution posted here, I am able to get hold of the hr, strong, br tags and move them into new td elements. However, I am not able to get hold of "some text 1" since it is directly contained within the td and using .text() on td will give me both "some text 1" as well as "some text 2".
Any idea?