Add rows, delete rows, and delete columns
1 <!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">2 <HTMLxmlns= "http://www.w3.org/1999/xhtml">3 <Head>4 <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" />5 <title>Untitled Document</title>6 <Scripttype= "Text/javascript">7 functionAddRow () {8 varTable=document.getElementById ("mytable"); 9 varrowindex=table.rows.length;Ten varRow=Table.insertrow (rowindex); One Row.insertcell (0). InnerHTML="3"; A Row.insertcell (1). InnerHTML="4"; - } - functiondelrow () { the varTable=document.getElementById ("mytable"); - varrowindex=table.rows.length; - Table.deleterow (rowindex-1); - } + functionDelcell () { - varTable=document.getElementById ("mytable"); + varrowindex=table.rows.length; A Table.rows[rowindex-1].deletecell (0); at } - </Script> - </Head> - - <Body> - <inputtype= "button"value= "Delete one row"onclick= "Delrow ()"/> in <inputtype= "button"value= "Add a row"onclick= "AddRow ()"/> - <inputtype= "button"value= "Cell Row"onclick= "Delcell ()"/> to <TableID= "MyTable"Border= "1"> + <TR><TD>1</TD><TD>2</TD></TR> - </Table> the </Body> * </HTML>
1. Operation
2. Add lines
3. Delete rows
4. Delete Columns
6. Adding rows, deleting rows, and deleting columns