gpt4 book ai didi

javascript - 单击第一个 时展开表格行以显示更多内容

转载 作者:行者123 更新时间:2023-11-28 11:53:02 25 4
gpt4 key购买 nike

我有一个基本表格,我希望能够展开表格行以查看有关该特定行的更多信息。

第一个 td 将有一个图标 (+) 以显示有更多内容,单击时我希望它在加号和减号图标之间切换,具体取决于行是展开还是折叠。

我有一个基本的演示: http://jsfiddle.net/e7X7H/1/

  $('table#hidden-table-info td.expand').click(function(){
alert("expand / collapse and change icons around");
});

任何帮助都会很棒谢谢

最佳答案

看看this fiddle

你要的JS是:

$('tr td:first-child img').click(function(){
var img=$(this);
if(img.attr('src')=='http://www.stemcor.com/images/plus.gif'){
// row expanded, so collapse...
img.attr('src','http://www.stemcor.com/images/minus.gif');
}else{
// row collapsed, so expand...
img.attr('src','http://www.stemcor.com/images/plus.gif')
}
})

关于javascript - 单击第一个 <td> 时展开表格行以显示更多内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20221948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com