DEV Community

loading...

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

Chukslord
Hello, I am ochuko, a python Web Developer and an aspiring dev ops engineer. I love coding, exploring the world and meeting new people.
・1 min read

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>

Discussion (0)