ulArry is a NodeList object. For in not only obtains two Dom nodes, but also length, item(), namedItem(). So when it reaches length, an error is reported. You can print out ulArry[i] in the loop and see
You can see why the error is reported by looking at the picture, but as for why there is a length in in, this i is worth waiting for the expert to answer
ulArry is a NodeList object. For in not only obtains two Dom nodes, but also length, item(), namedItem(). So when it reaches length, an error is reported.
You can print out ulArry[i] in the loop and see
You can see why the error is reported by looking at the picture, but as for why there is a length in in, this i is worth waiting for the expert to answer
Put the code into $(function(){}) and try it
for in will report an error but for will not. The second ul class is not just one, but two. It is recommended to getElementsByTagName
Please make sure the document is loaded before proceeding