如果使用这样的 dom 命令:
document.contains(document.querySelectorAll('div#my#item div')[1].querySelector('a').innerHTML)
我收到这个:
Uncaught TypeError: Failed to execute 'contains' on 'Node': parameter 1 is not of type 'Node'.(…)
如何修复我的查询以接收 true 或 false?
最佳答案
删除innerHTML
document.contains(document.querySelectorAll('div#my#item div')[1].querySelector('a'));
包含
checks对于节点而不是 html 字符串
关于javascript - 文档包含在列表/计数器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34709100/