What do you think of this? $('img.toWrap').each(function(i) { var img = $(this); var table = $('<table><tr><td>Content</td></tr><tr><td\ class="imageHere"></td></tr><tr><td>\ More Content</td></tr></table>'); table.insertBefore(img); table.find('td.imageHere').append(img); });
JK ________________________________________ From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Glen Lipka Sent: Monday, October 15, 2007 2:18 PM To: jquery-en@googlegroups.com Subject: [jQuery] Re: Is there a way to wrap a table around content with jQuery? Tricky problem. I found one way, but there MUST be an easier way. Demo: http://www.commadot.com/jquery/wrapTable.php# Maybe try the flydom plugin? Glen On 10/15/07, Chris - Implied By Design < [EMAIL PROTECTED]> wrote: Hello, I'm running into some trouble trying to wrap a table around some content. The table looks like this: <table> <tr><td>Content</td></tr> <tr><td>[image to be wrapped around]</td></tr> <tr><td>More Content</td></tr> </table> I've been experiementing with the most of the API DOM manipulation functions, but none of them seem to do the trick. I'd like to use something like wrap(), but wrap will inject the content into the first <td>, rather than the middle one. I tried putting a div in the middle cell to see if jQuery would then consider it the deepest element, but it still adds it to the first <td>. Any ideas? Thoughts would be much appreciated! Thanks! Chris