Select part of text in a tag

Posted by atlantis on Stack Overflow See other posts from Stack Overflow or by atlantis
Published on 2010-04-30T11:30:18Z Indexed on 2010/04/30 12:37 UTC
Read the original article Hit count: 310

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about dom