TriSTaR TriSTaR - 2 months ago 5
CSS Question

Jquery .prependTo() use for the tag

how to use prependTo to add class

<div class="table-responsive">
above tag table?

I know how it works, but it is before the TABLE tag does not put the div with the class

Answer

You can use wrap():

$( "table" ).wrap( "<div class='table-responsive'></div>" );
.table-responsive{
  border:solid 1px red;
  }

table, td{
    border:solid 1px green;
  }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
  <tr>
    <td>1</td>
    <td>2</td>
  </tr>
</table>

Comments