你不應(yīng)該使用forEach,因?yàn)镠TMLCollections沒有實(shí)作forEach方法。
forEach
使用for迴圈
const a = document.getElementsByTagName('body')[0] const d = a.getElementsByTagName('h1') for (let elem of d) { elem.innerHTML = '新文本' }