This article mainly introduces the JS simple table add row and delete line operations, the need for friends can refer to the following
Code as follows: <html> <head> <script src= "Http://code.jquery.com/jquery-1.11.0.min.js" > </script> <script> //Create an HTML element function $c (tagname) { return Document.createelement (tagname); } //document to be executed after loading $ (document). Ready (function () { // The Click event $ ("#addrow") of the Bind Add Row button. Bind ("click", Function () { //Get table var tab = $ ("#tab"); //Create TR Elements & nbsp var tr = $c ("tr"); //+ for table append TR element Tab.append (TR); //create TD element VAR td1= $c ("TD"); //TD element Content &NB Sp Td1.innerhtml= "Insert1"; //Add TD Element Tr.appendchild (TD1); var td2= $c ("TD") to the newly appended TR; Td2.innerhtml= "Insert2"; tr.appendchild (TD2); }); //Bind click event $ ("#deleterow") to delete Row buttons. Bind (" Click, function () { //Get first line of table var tab = $ ("#tab tr:eq (0)"); //delete this row Tab.remove (); }); &n Bsp }); </script> </head> <body> <table border= '1 ' id= ' tab ' > <tr> <td>123</td> <td>456</td> </tr> </table> </br> <button id= "AddRow" > Add line </button> <button id= " DeleteRow "> Delete line </button> </body> </html>