Insert multiple rows in the table, and use features similar to insertAdjacentHTML
<Html> <body> <table id = tableList border = 1 width = 100> <tr> <td> 1 </td> </tr> </table> <button onclick = addRow ()> insert row </button> </body> <script type = "text/javascript"> var num = 1; function addRow () {num ++; InsertRow (tableList, "<tr> <td>" + num + "New Line </td> </tr>");} function InsertRow (table, rowHtml) {var o = document. createElement ("p"), ol; o. innerHTML = "<table>" + rowHtml + "</table>" ol = o. childNodes [0]. tBodies [0]. rows while (ol. length> 0) {table. tBodies [0]. appendChild (ol [0])} script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
The tBodies attribute of Table is a set in JS, rather than an array. There is no sort () method, so it cannot be used for direct sorting.