[英]How do I extract texts only without html markup?
我試圖通過使用innerText
提取沒有html
標記的texts
。
//table is a html table structure
var cells = table.innerText.trim()
像cells
數據如下:
1st cell
2nd cell
3rd cell
4th cell
last cell
如何將每個單元格數據放入array
?
我努力了
cells = cells.split(' ');
但這不起作用。
這里有什么幫助嗎? 非常感謝!
只需從每個單元格中提取文本即可:
var arr=[],
rowCells,
myRows=table.rows;
for (var i=0; i<myRows.length; i++) {
rowCells=myRows[i].cells;
for (var j=0; j<rowCells.length; j++) {
arr.push(rowCells[j].innerText.trim());
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.