[英]Function doesn't work in safari on windows
While this syntax works on all other browser, safari on windows throws an error 尽管此语法可在所有其他浏览器上使用,但Windows上的Safari浏览器会引发错误
$("#kibana").contents().find('.navbar-nav')[0].remove();
The error is 错误是
TypeError: 'undefined' is not a function
The element does exist. 该元素确实存在。 I checked using the debugger.
我使用调试器进行了检查。
Why is this happening? 为什么会这样呢?
When you use []
on a jQuery object, you are retrieving the underlying DOM node. 在jQuery对象上使用
[]
时,您正在检索基础DOM节点。 .remove
isn't fully cross-browser compatible on native DOM elements. .remove
在本机DOM元素上不完全跨浏览器兼容。
Instead, you can use .eq
to retrieve the element while still having it wrapped in jQuery. 相反,您可以使用
.eq
来检索元素,同时仍将其包装在jQuery中。 That way you can use the cross-browser comptabile .remove
method: 这样,您可以使用跨浏览器的comptabile
.remove
方法:
$("#kibana").contents().find('.navbar-nav').eq(0).remove();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.