【问题标题】:Toggling table row changes width of columns in other rows切换表格行更改其他行中列的宽度
【发布时间】:2011-09-01 11:04:37
【问题描述】:

我有一张如下表:

<table width="100%">
<tr class="clickme">
    <td width="1%">A</td>
    <td>B</td>
    <td width="50px">C</td>
    <td width="50px">D</td>
</tr>

<tr class="contain">
    <td colspan="4">Lorem Ipsum</td>
</tr>
</table>

还有下面的js

$(function(){
    $('.clickme').click(function(){
        $(this).next('tr').toggle();
     });
});

对于 Opera 这很好,但是,在 IE 和 Firefox 中,当我切换 .contain 表行时,.clickme 表行的所有列的宽度都会发生变化,有人知道为什么吗?

【问题讨论】:

  • 什么浏览器和平台?我看不到你在这个JS Fiddle reproduction 中描述的效果。 (background-color 没有区别,只是这样我可以清楚地看到我在哪一行。)在 Ubuntu 11.04、Firefox 4、Chromium 11 和 Opera 11 上测试。
  • 无法在 FF4 和 IE8 中重现。
  • 你能不能把你的表格宽度设为固定值试试?
  • 它在 FF 4.0 上运行良好。检查 jsfiddle here
  • 工作正常:见jsfiddle.net/xkeshav/gRSAV问题出在哪里??

标签: jquery html-table row toggle


【解决方案1】:

试试这个功能:

$(this).siblings().toggle();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-25
    • 2016-08-07
    • 2014-12-15
    • 2012-06-28
    • 1970-01-01
    • 2011-06-01
    • 2014-01-06
    • 2014-10-31
    相关资源
    最近更新 更多