【发布时间】:2017-07-10 17:25:38
【问题描述】:
如果html表中一行的第3个字段是
所有“狗”都去天堂。
浏览器控制台将显示以下内部列表(在调用函数 filldb() 之后)。请注意表的该行/字段和结果列表元素中的 textContent 中的不匹配的内部引号。
["1", "101", "3/S4.1", "All "dogs' go to heaven.", "4*3*2", "5", "60", "1", "30-00.0", "750.96"]
function filldb(){
estRows=[];
rows=e_tbody.rows;
// 'rows' is now the collection of rows in your dynamically output table.
var len=rows.length;
var lnItm=[];
for(var i=0; i<len; i++){
lnItm=[];
lnItm.push(rows[i].cells[0].textcontent);
lnItm.push(rows[i].cells[1].textcontent);
lnItm.push(rows[i].cells[2].textcontent);
lnItm.push(rows[i].cells[3].textcontent);
--- <snip> ---
lnItm.push(rows[i].cells[9].textcontent);
estRows.push(lnItm);
}
for(var i=0; i<len; i++){
console.log(estRows[i]);
}
}
我很困惑 JavaScript 数组的元素如何成为无效字符串。解释?关于 textContent 没有被解析的问题?
【问题讨论】:
-
JavaScript 区分大小写 ->
textcontent !== textContent -
"All "Dogs' go to heaven."该报价预计将在天堂之后关闭。但它在 Dogs 之前就关闭了。 -
"All "Dogs' go to heaven."应该类似于"All \"Dogs' go to heaven."
标签: javascript html arrays html-table