【发布时间】:2017-07-17 17:26:12
【问题描述】:
我尝试使用 JavaScript 更改表格中行的背景,但它不起作用。 这是我的code。但是,我尝试使用 html 及其工作创建一个表。 P.S : 我想用 webkit。
代码:
var table = document.getElementById("tab");
var rowCount = table.rows.length;
for(var i=0;i<6;i++) {
row = table.insertRow(rowCount);
row.id = "row"+i;
cell1 = row.insertCell(0);
var content = document.createElement("output");
content.innerHTML = i ;
cell1.appendChild(content);
rowCount++;
}
$(document).ready(function(){
$('td').each(function(i) {
$('#tab').on('click', '#row'+i, function(){
document.getElementById("row"+i).style.background = 'white';
//alert(i);
});
});
//example2
$('#td1').on('click', function(){
document.getElementById("td1").style.background = 'white';
});
});
【问题讨论】:
-
不要“使用 webkit”——使用标准。绝对不要使用outdated webkit gradient specification。
标签: javascript jquery css background html-table