【发布时间】:2020-07-04 11:55:48
【问题描述】:
我有这个错误
Uncaught TypeError: trList.forEach is not a function
在这个函数中
function findMatchingRow(word) {
const found = []
const trList = document.querySelectorAll('#main_table_countries_today > tbody > tr')
trList.forEach(function(tr, i) {
if(tr.textContent.match(word)) {
found.push({index: i, content: tr.textContent})
}
})
return found
}
{const matches = findMatchingRow('Tunisia')
console.log(matches)
if(matches.length > 0) {
console.log('found at:', matches.map(function(m) { return m.index; }))}}
我认为这个问题与 ES6 兼容性有关
【问题讨论】:
标签: javascript android jquery webview