【问题标题】:Expand and Collpse row on click row点击行展开和折叠行
【发布时间】:2016-02-02 00:01:47
【问题描述】:

我搜索了用于展开和折叠行的参考。但是在我的脚本上它不起作用,这是我的脚本:

    <thead>   
    <tr>
        <th width="5" class="cb"><input type="checkbox" id="cbcall" /></th>

        <th> Domain</th>
        <th> Total Member</th>
        <th> Monthly Growth</th>
        <th> Growth % </th>
    </tr>
</thead>
<tbody>
    <?php foreach ( $this->paging as $kk=>$dom ): ?>
    <tr>
        <tr class="header" style="cursor:pointer;">
            <th><input type="checkbox" name="cb[]" value="<?php echo $dom['m'] ?>" /></th>
            <th colspan="3"><i class="fa fa-chevron-circle-right"></i>&nbsp<strong><?php echo $this->escape($dom['member_domain'])?></strong></th>
            <th></th>
        </tr>
        <?php foreach ( $this->paginator as $k=>$value ): ?>
            <tr>
            <?php if ($this->escape($value['member_domain']) == $this->escape($dom['member_domain'])){?>
                    <td></td>
                    <td><?php echo '&nbsp&nbsp&nbsp&nbsp&nbsp'.$this->escape($value['member_client']) ?> </td>
                    <td><center><?php echo $this->escape($value['1_month']) ?></center></td>
                    <td><center><?php echo $this->escape($value['1_month'])-$this->escape($value['2_month']) ?></center></td>
                    <td><center>
                        <strong><?php echo number_format((100 * ($this->escape($value['1_month'])-$this->escape($value['2_month'])))/$this->escape($value['1_month']),0)."%" ?>
                        </strong>
                        </center>
                    </td>
            <?php } ?>
            </tr>
        <?php endforeach; ?>    
    </tr>
    <?php endforeach; ?>
</tbody>

编辑

这是我的脚本:

$('.header').click(function(){
    $(this).nextUntil('tr.header').slideToggle(100, function(){
    });
});

视图看起来像:

my view

我想在点击“域名”时进行展开和折叠。

这个方法我用过,没用:

expand/collapse table rows with JQuery

使用 jQuery 1.110。有人帮忙吗??

【问题讨论】:

  • 我没有使用过 PHP,但使用过 JavaScript,您在控制台中看到任何错误吗?
  • 您链接的帖子中有几种(工作)方法,我们不知道您的实际脚本是什么,以及您何时执行它。请将相关代码添加到您的帖子中。
  • @RahulSharma 一切都很干净,先生,我的控制台上没有红色文字 :(
  • @Teemu 对不起,我忘了添加我的 js ..

标签: javascript jquery collapse expand


【解决方案1】:

$(document).ready(function(){
	$(".open-bext").click(function(){
    	$(this).parents("tr").next("tr").show();
    });
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<table>
    <tr>
        <td><a href="#" class="open-bext">Open</a>
        </td>
    </tr>
    
    <tr class="detail" style="display: none">
        <td>content will come here
        </td>
    </tr>
    <tr>
        <td><a href="#" class="open-bext">Open</a>
        </td>
    </tr>
    
    <tr class="detail" style="display: none">
        <td>content will come here
        </td>
    </tr>
    <tr>
        <td><a href="#" class="open-bext">Open</a>
        </td>
    </tr>
    
    <tr class="detail" style="display: none">
        <td>content will come here
        </td>
    </tr>
</table>

【讨论】:

  • 代码不全,但对你有帮助
  • 感谢回复,我不知道为什么没有方法适合我:(
猜你喜欢
  • 1970-01-01
  • 2016-08-25
  • 2018-12-24
  • 2014-06-30
  • 2021-12-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多