在遍历一个p节点时用了createNodeIterator()方法报错
css.html:9 Uncaught TypeError: Failed to execute 'createNodeIterator' on 'Document': parameter 1 is not of type 'Node'.
at css.html:9
代码是
HelloWorld!!!
- Item1
- Item2
- Item3
请指教
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
应该是脚本执行的时候,还没有
<p id="p1">,var p = document.getElementById("p1");获取到的其实是空值,document.createNodeIterator的第一个参数是不能为空的。把脚本放到尾部试试。