document.querySelectorAll(…).remove is not a function"
document.querySelectorAll('.esedbox .triangle_b').remove()
因为document.querySelectorAll(‘.esedbox .triangle_b’)返回的不是数组,而是类数组,不能用remove方法(remove方法是dom元素节点的方法)
Array.from()方法主要用于将两类对象(类似数组的对象[array-like object]和可遍历对象[iterable])转为真正的数组。
正确的写法:
const cleardom = document.querySelectorAll('.esedbox .triangle_b, .triangle_p')
Array.from(cleardom).forEach((item) => {
item.remove()
})