Failed to execute ‘getComputedStyle’ on ‘Window’ jQuery使用过程中报错
在写js的过程中,遇到了Failed to execute ‘getComputedStyle’ on ‘Window’的报错,原因很简单,就是我通过选择器定位的元素其实根本不存在!
本来要定位 $(“body #node2”),写了$(“body #node2”).show(),但页面上根本没有id为node2的元素在,然后就报出这样的错。。。希望我下次能仔细点。。。
但是!!写 $(“body #node2”).hide()是完全没有问题的,即使元素不存在。。。
本文探讨了在使用jQuery过程中遇到的“Failed to execute 'getComputedStyle' on 'Window'”错误,并分享了解决方法。作者原本尝试显示一个不存在的元素,结果导致报错。文章还提到即使元素不存在,使用.hide()方法也不会引发错误。
3624





