Home > Enterprise >  How do I add a tooltip to a dynamically created table row in javascript?
How do I add a tooltip to a dynamically created table row in javascript?

Time:01-19

I want to add a tool-tip for each of the table rows that are being created in a HTML table:

document.getElementById("insert").addEventListener("click",function(){
    table.insertRow(table.rows.length);

    //add a tooltip for each row
})

How do I go about it?

CodePudding user response:

you can use setAttribute methods.

document.getElementById("insert").addEventListener("click",function(){
    //add a tooltip for each row
var newRow = table.insertRow(table.rows.length);
      newRow.setAttribute("title", "tooltip text");
})

  
  • Related