[英]remove() function undefined in IE11
當我在Chrome上運行頁面時,一切正常,但在IE11上運行時,找不到remove()
函數。
function restartAnimatorSelf() {
var el = $('#selfLabel'),
newone = el.clone(true);
el.before(newone);
var child = $("#popSelf").children()[1];
$("#popSelf").children()[1].remove();
}
問題是因為您正在按索引訪問jQuery對象,該索引返回的是Element對象,而不是jQuery對象。 這樣,您將調用本機JS remove()
方法,而不是IE中不支持的jQuery方法。
要解決此問題,請使用eq()
通過索引檢索元素:
var $child = $("#popSelf").children().eq(1);
$child.remove();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.