Find text after img tag and create p tag for the text is this possible with jquery please help me
See here ;
<p>
<img src="img.jpg" />
Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet
</p>
This is my HTML code i need to create like this
<p>
<img src="img.jpg" />
<p>Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet Lorem ipsum dolor sit amet</p>
</p>
Is this possible with jquery
You can find the next sibling of the
img
elements and see whether it is an non-empty text node, if so then wrap it with ap
node using .wrap()Demo: Fiddle