【问题标题】:"removeAttribute is not a function" error message“removeAttribute 不是函数”错误消息
【发布时间】:2011-01-26 01:55:54
【问题描述】:

mac firefox 3.6.13 firebug 给我这个错误:“removeAttribute 不是函数” 我在某处读到“removeAttribute”在某些浏览器中存在错误,但我需要使用它。如果是浏览器问题,谁能提出不同的方法。

function closeThumbView(){
  $("#thumbReelBox").fadeOut(1000, function(){
    $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox").removeAttribute('style');
    });
}

【问题讨论】:

    标签: jquery css function


    【解决方案1】:

    removeAttribute 是一个 JavaScript DOM 函数。由于您使用 $(),因此对 jQuery 对象进行操作,因此您需要使用 jQuery 等价物 removeAttr()

    【讨论】:

      【解决方案2】:

      尝试使用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');
          }
        });
      }
      

      或者如果您想使用 JQuery 方法,请使用removeAttr(),正如一位受访者所说:

      function closeThumbView(){
        $("#thumbReelBox").fadeOut(1000, function(){
          els = $("#thumbReelList > li > a, #thumbReelList > li, #thumbReelNav, #thumbReelBox");
          els.removeAttr('style');
        });
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-16
        • 2018-09-06
        • 2016-10-23
        • 1970-01-01
        • 2016-06-05
        • 1970-01-01
        • 2021-12-10
        相关资源
        最近更新 更多