-2

i have search for reference that used to expand and collapse row. But on my script its doesn't work, this is my script:

    <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>

edit

and this is my script:

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

and the view look's like:

my view

i want to make an expand and collapse when the "Domain" name is click.

i have used this method and didn't works:

expand/collapse table rows with JQuery

iused jQuery 1.110. anyone help??

aynber
  • 22,380
  • 8
  • 50
  • 63

1 Answers1

0

$(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>
Mitul
  • 3,431
  • 2
  • 22
  • 35