Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"removeAttribute is not a function" error message

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.

function closeThumbView(){
  $("#thumbReelBox").fadeOut(1000, function(){
    $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox").removeAttribute('style');
    });
}
like image 752
Joshua Robison Avatar asked Jan 26 '11 01:01

Joshua Robison


2 Answers

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()

like image 69
Jason LeBrun Avatar answered Oct 19 '22 11:10

Jason LeBrun


Try to use DOM element removeAttribute() method:

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:

function closeThumbView(){
  $("#thumbReelBox").fadeOut(1000, function(){
    els = $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox");
    els.removeAttr('style');
  });
}
like image 12
ikostia Avatar answered Oct 19 '22 10:10

ikostia