Best way to switch wrapping elements using jQuery
jquery
Solution
You could create a table with a tr and td, insert the HTML contents from the span into that new td element, insert the table immediately after the span, and then finally, remove the span.
$("<table id='t'><tr><td>" + $("#s").html() +
"</td></tr></table").insertAfter("#s");
$("#s").remove();
I'm assuming by "swipe" you mean "swap"? So that's why I've removed the original span. If this is not the case, just leave out the `remove` call.
Problem
I have this code in HTML ``` <span id="s">Attachments</span> ``` How to use jQuery to switch the outer SPAN element with the following table code block, so that the "Attachments" text becomes wrapped with the table element. ``` <table id="t"> <tr> <td>Attachments</td> </tr> </table> ```