You can't split up a tag like that. Whatever you pass into functions like prepend(), append(), or html() will be treated (if possible) as a complete tag.
It would help to know *exactly* what result you are looking for. I'm guessing you want to have it end up like this: <table> <tr> <td><input value="abc" /></td> <td><input value="def" /></td> <td><input value="ghe" /></td> </tr> </table> Is that right? BTW, I assume that the extra ">" characters in the second and third <td> tags is just a typo in your example, and your actual code is valid HTML? Here is how you could do it: $('table>td').each( function( i, td ) { var $td = $(td); $td.html( '<input type="text" value="' + $td.find('p').text() + '" />' ); }); Also instead of 'table>td' as your selector, I'd suggest giving the table an id or class attribute and using that in the selector - otherwise your code will operate on *all* tables on your page. Finally, note that I switched your quotes around, using single quotes for JavaScript strings and double quotes for attributes. It will work either way, but valid HTML requires double quotes for attributes. It's worth getting in the habit of using single quotes for your JavaScript strings, so you can easily use double quotes for attributes inside those strings. -Mike On Sat, Nov 21, 2009 at 1:35 PM, navid zehi <navid.z...@gmail.com> wrote: > hello all > > I have a problem with wraping a text or html with a tag, but the text > should be placed in an attribute . > > for example : > > i have a table like this > > <table> > <tr><td><p>abc</p></td> > <td>><p>def</p></td> > <td>><p>ghe</p></td></tr> </table> > > i want to change each of the TDs to Textbox with value of its TD . > > i used this : $('table td p').prepend("<input type='text' value=' > ").append(" '>"); > > but the result acted as text and not HTML . > > plz someone help me , tnx >