Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert <div> tag within a <td> tag using JQuery

Tags:

jquery

How to insert <div> within a <td> using JQuery and place all the child elements of <td> within the <div>?

Lets say I have the HTML rendered in the below mentioned format.

<td class="known_td">
  <input ../>
  <img ../>
</td>

The updated HTML should look like,

<td class="known_td">
  <div>
    <input ../>
    <img ../>
  </div>
</td>
like image 280
R K Avatar asked Feb 23 '12 19:02

R K


1 Answers

$('.known_td').wrapInner('<div />');

Update:

It's worth noting that you can treat the tag passed to wrapInner() as a normal html element declaration, adding classes, ID, etc:

$('.known_td').wrapInner('<div id="neo" class="dynamic" />');

Cheers

like image 83
Madbreaks Avatar answered Sep 16 '22 16:09

Madbreaks