javascript - Add new column to HTML table which has not table id -
how can add new column in below code, need happen if there no table id or tr id or td id.
please check , tell me
<p>click button insert new cell(s) @ beginning of table row.</p> <table> <tr> <td>first cell</td> <td>second cell</td> <td>third cell</td> </tr> </table><br> <button onclick="myfunction()">try it</button> <script> function myfunction() { var row = ?????????????? var x = row.insertcell(0); x.innerhtml = "new cell"; } </script>
you can use getelementsbytagname
access tables.
var row = document.getelementsbytagname("table")[0].rows[0];
Comments
Post a Comment