首页 > 其他 > 详细

实现表格中每行展开收起内容

时间:2019-05-10 10:18:07      阅读:223      评论:0      收藏:0      [点我收藏+]

效果图:

技术分享图片

 

 

html:

<table>
                                <tr>
                                    <th style="width:130px;">类型</th>
                                    <th style="width:138px;">测试</th>
                                    <th style="width:90px;">途径</th>
                                    <th style="width:100px;">数据</th>
                                    <th>剂量</th>
                                    <th style="width:250px;">作用</th>
                                </tr>
                                <tr class="item-tr">
                                    <td>ree</td>
                                    <td>tgtg</td>
                                    <td>fgfgf/td>
                                    <td>fhghg </td>
                                    <td>643 mg/kg</td>
                                    <td>
                                        <ul>
                                            aaa
                                            <a class="unfold" href="javascript:;">查看</a>
                                        </ul>
                                    </td>
                                </tr>
                    
                  <tr class="doc-tr none">
                                    <td colspan="6">
                                        <div class="document">
                                            <span>detail:</span>
                                            <p>aaaaartrtrrytry</p>
                                        </div>
                                    </td>
                                </tr>
                  <tr class="item-tr">
                                    <td>ree</td>
                                    <td>tgtg</td>
                                    <td>fgfgf/td>
                                    <td>fhghg </td>
                                    <td>643 mg/kg</td>
                                    <td>
                                        <ul>
                                            aaa
                                            <a class="unfold" href="javascript:;">查看</a>
                                        </ul>
                                    </td>
                                </tr>
                    
                  <tr class="doc-tr none">
                                    <td colspan="6">
                                        <div class="document">
                                            <span>detail:</span>
                                            <p>aaaaartrtrrytry</p>
                                        </div>
                                    </td>
                                </tr>
                  <tr class="item-tr">
                                    <td>ree</td>
                                    <td>tgtg</td>
                                    <td>fgfgf/td>
                                    <td>fhghg </td>
                                    <td>643 mg/kg</td>
                                    <td>
                                        <ul>
                                            aaa
                                            <a class="unfold" href="javascript:;">查看</a>
                                        </ul>
                                    </td>
                                </tr>
                    
                  <tr class="doc-tr none">
                                    <td colspan="6">
                                        <div class="document">
                                            <span>detail:</span>
                                            <p>aaaaartrtrrytry</p>
                                        </div>
                                    </td>
                                </tr>


                                
</table>

 

 

js:

 $(‘table .item-tr a‘).click(function(){
    // $(this)
    if($(this).attr("class")=="unfold"){
      console.log(111)
      $(this).closest(‘.item-tr‘).next().show()
      $(this).removeClass(‘unfold‘).addClass(‘fold‘).text(‘收起‘)
    }else{
      $(this).closest(‘.item-tr‘).next().hide()
      $(this).removeClass(‘fold‘).addClass(‘unfold‘).text(‘查看‘)
    }
  })

 

实现表格中每行展开收起内容

原文:https://www.cnblogs.com/wszxx/p/10842724.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!