How to insert a <div> tag in a <td> tag using jQuery

How to insert <div>in <td>using jQuery and put all child elements <td>in <div>?

Suppose I have HTML presented in the format below.

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

Updated HTML should look like this:

<td class="known_td">
  <div>
    <input ../>
    <img ../>
  </div>
</td>
+5
source share
1 answer
$('.known_td').wrapInner('<div />');

Update:

It is worth noting that you can handle the tag passed to wrapInner () as declaring a regular html element by adding classes, identifier, etc.:

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

Greetings

+11
source

All Articles