DEV Community


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

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

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

Discussion (0)