jQuery “removeAttribute 不是函数”错误消息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4800769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"removeAttribute is not a function" error message
提问by Joshua Robison
mac firefox 3.6.13 firebug gives me this error: "removeAttribute is not a function" I have read somewhere that "removeAttribute" is buggy in some browsers however I need to use it. If it is a browser problem can anyone suggest a different method.
mac firefox 3.6.13 firebug 给我这个错误:“removeAttribute is not a function” 如果是浏览器问题,任何人都可以提出不同的方法。
function closeThumbView(){
$("#thumbReelBox").fadeOut(1000, function(){
$("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox").removeAttribute('style');
});
}
回答by Jason LeBrun
removeAttribute is a JavaScript DOM function. Since you are using $(), and thus operating on a jQuery object, you need to use the jQuery equivalent, removeAttr()
removeAttribute 是一个 JavaScript DOM 函数。由于您使用的是 $(),因此对 jQuery 对象进行操作,因此您需要使用 jQuery 等效项 removeAttr()
回答by ikostia
Try to use DOM element removeAttribute()method:
尝试使用 DOM 元素removeAttribute()方法:
function closeThumbView(){
$("#thumbReelBox").fadeOut(1000, function(){
els = $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox");
for(ind=0;ind<els.length;ind++){
els[ind].removeAttribute('style');
}
});
}
or if you want to use JQuery method, use removeAttr()as one of the respondents said:
或者,如果您想使用 JQuery 方法,请使用removeAttr()作为受访者之一说:
function closeThumbView(){
$("#thumbReelBox").fadeOut(1000, function(){
els = $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox");
els.removeAttr('style');
});
}