cell.innerHTML()的Javascript问题
我试图为某些表格单元格提供一个令人敬畏的字形。这是通过使用适当的CSS类实现的,例如cell.innerHTML()的Javascript问题,javascript,font-awesome,Javascript,Font Awesome,我试图为某些表格单元格提供一个令人敬畏的字形。这是通过使用适当的CSS类实现的,例如 以下是我迄今为止尝试过的JS: function addRow(tableID,rowData) { if (Array.isArray(rowData) && rowData.length>0) { var myTab=document.getElementById(tableID).getElementsByTagName('tbody')[0];
以下是我迄今为止尝试过的JS:
function addRow(tableID,rowData) {
if (Array.isArray(rowData) && rowData.length>0) {
var myTab=document.getElementById(tableID).getElementsByTagName('tbody')[0];
var newRow = myTab.insertRow();
rowData.forEach(function (item) {
console.log(item);
var newCell = newRow.insertCell();
// THIS : createTextNode + appendChild = WORKS OK (no "err") !
//var newText = document.createTextNode(item);
//newCell.appendChild(newText);
// SWITCHING TO THIS = WORKS OK (no "err" in console)
//newCell.innerHTML='';
// BUT THIS YIELDS "err" in console
//newCell.innerHTML(item);
});
}
}
该函数的输入示例如下:
var foobar = ['a','b','c','test+a@example.com','10/10/10 10:10','<i class="fa fa-check-square-o fa-2x foobar-status-green"></i>',false];
var foobar=['a','b','c','test+a@example.com“,”10/10/10:10“,”,假];
innerHTML
不是一个函数,它是一个属性,不使用括号,直接写下:
newCell.innerHTML = item;
不必先写:
newCell.innerHTML = ''; // not needed
innerHTML
不是一个函数,它是一个属性,不使用括号,直接写下:
newCell.innerHTML = item;
不必先写:
newCell.innerHTML = ''; // not needed
newCell.innerHtml
不是在元素上定义的函数。您需要将其用作setternewCell.innerHtml=item
newCell.innerHtml
不是在元素上定义的函数。您需要将其用作setternewCell.innerHtml=item
“THIS:createTextNode+appendChild=WORKS OK”和“切换到THIS=WORKS OK”那么……有什么问题吗innerHTML
是一个字符串属性,而不是一个函数。“这个:createTextNode+appendChild=WORKS OK”和“切换到THIS=WORKS OK”那么……有什么问题吗innerHTML
是字符串属性,而不是函数。