簡體   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