2013-12-20 40 views
1

我在看: 用jQuery展开表格行 - jExpand插件。jQuery - jExpand插件 - 通过图像展开?

http://www.jankoatwarpspeed.com/expand-table-rows-with-jquery-jexpand-plugin/

此我想要做什么,但我只希望该行可切换通过箭头图标,而不是通过单击整个行上。

我试过改变$("#report tr.odd").click(function(){来拾取箭头类,但没有任何工作。

难道有人指着我正确的方向!

+0

你可以,请发布'JSFiddle'包含你的尝试? –

回答

2

有两个变化,你需要做

CSS变化:

#report tr.odd td { background:#fff url(row_bkg.png) repeat-x scroll center left; } 
.arrow { cursor:pointer;} 

JavaScript的变化:

$(".arrow").click(function(){ 
    $(this).parents("tr").next("tr").toggle(); 
    $(this).toggleClass("up"); 
}); 

http://jsfiddle.net/566aT/3/

+0

感谢这工作很好:) – MacMan

0

你必须改变点击绑定到箭头,然后确保您回到TR上下文。这里是一个fiddle

$("#report tr.odd .arrow").click(function(){ 
       $(this).closest('tr').next("tr").toggle(); 
       $(this).closest('tr').find(".arrow").toggleClass("up"); 
      }); 
      //$("#report").jExpand(); 
     });