jQuery wrap span around text
javascript, jquery, text
Solution
For your current example here is my one line solution:
$("div span").detach().prependTo($("div").contents().wrap("<span />").end());
DEMO: http://jsfiddle.net/awwTA/
Problem
I have the following ``` <div><span class="myspan">hello</span> this text has no span </div> ``` In jQuery, how can I wrap a `div` or span around the "this text has no span" text?