当前位置: 代码迷 >> Web前端 >> IE8上, jQuery :hidden函数在TR下的bug与解决办法
  详细解决方案

IE8上, jQuery :hidden函数在TR下的bug与解决办法

热度:86   发布时间:2012-10-30 16:13:36.0
IE8下, jQuery :hidden函数在TR上的bug与解决方法

该问题主要产生在ie8下对tr标签隐藏后统计其个数时出现
下面是一段官方的解释:
There is an open ticket for this. It is interesting because IE says that the TR element still has a width > 0 even though it isn't displayed. If you check the TD of the hidden TR, it is hidden.

解决方法,通过行的css样式获取display值来判断当前行是否是隐藏状态
详细代码如下:

var hideCount=0;
jQuery("#dataList tr").each(function(){
     var curTR=jQuery(this);
     var display=curTR.css("display");
     if(display=="none"){
        hideCount=hideCount+1;
     }
});

?上面方法 ie6,ie7,ie8,ff测试通过

?

  相关解决方案