DEV Community

Chukslord
Chukslord

Posted on

Answer: How to insert row with attributes using table.insertRow?

To set the class name for a tablerow you simply need to edit the className attribute as done below

<script>
var table = document.getElementById("tableID");
var rowCount = table.rows.length;
var row = table.insertRow(rowCount-1);
row.className = "rowdiv";
</script>

Top comments (0)