For instance:
FROM
<div>
whats up!
<div> whats up2! </div>
thank you for your help
<div></div>
</div>
TO
<div>
<span>whats up!</span>
<div><span> whats up2! </span></div>
<span>thank you for your help</span>
<div></div> <!---STAYS THE SAME -->
</div>
How would I make something like this in jQuery or pure JavaScript?
Having this HTML:
You could do something like this:
As far as I know, you can’t get text nodes with jQuery (correct me if I’m wrong please’), so you can get them with pure JavaScript and use jQuery’s method wrap
http://jsfiddle.net/hyJA6/2/