[英]How do I dynamically add an input field into a cell inside my html table row in 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.