jquery - How to replace between existing table rows in JavaScript -
i trying regenerate table new order, problem encounter in performance, have this:
<table> <tr id="row1"></tr> <tr id="row2"></tr> <tr id="row3"></tr> <tr id="row4"></tr> </table>
obviously table more complex, solution performance replacing command target table should like:
<table id="maintable"> <tr id="row3"></tr> <tr id="row4"></tr> <tr id="row1"></tr> <tr id="row2"></tr> </table>
when redraw performance bad(for more 100 lines) there way replace rows between without redrawing it? thanks
for rearranging them append them using append()
or next()
$table = $('#maintable'); $table.append($('#row1,#row2', $table));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <table id="maintable"> <tr id="row1"> <td>1</td> </tr> <tr id="row2"> <td>2</td> </tr> <tr id="row3"> <td>3</td> </tr> <tr id="row4"> <td>4</td> </tr> </table>
Comments
Post a Comment