繁体   English   中英

如何向 javascript 中动态创建的表格行添加工具提示?

[英]How do I add a tooltip to a dynamically created table row in javascript?

我想为HTML表中创建的每个表行添加一个工具提示:

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

    //add a tooltip for each row
})

我怎么go一下呢?

您可以使用 setAttribute 方法。

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

  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM