码迷,mamicode.com
首页 > Web开发 > 详细

jquery 删除table行,该如何解决

时间:2017-06-09 11:50:06      阅读:225      评论:0      收藏:0      [点我收藏+]

标签:color   解决方案   span   class   api   com   tab   style   删除   

query 删除table行
< table >
  < tbody >
  < tr >
  < td > 这行原来就有 </ td >
  < td >< button class = " del " > 删除 </ button ></ td >
  </ tr >
  < tr >
  < td > 这行原来就有 </ td >
  < td >< button class = " del " > 删除 </ button ></ td >
  </ tr >
  </ tbody >
</ table >
用jquery动态的给button加上click事件,并且能够删除行。
哥哥们,怎么做?

------解决方案--------------------

HTML code
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<table>
<tbody>
<tr>
<td>这行原来就有</td>
<td><button class="del">删除</button></td>
</tr>
<tr>
<td>这行原来就有</td>
<td><button class="del">删除</button></td>
</tr>
</tbody>
</table>
<script>
    $(‘button.del‘).live(‘click‘, function(){
        $(this).parents(‘tr‘).remove();
    })
</script>

jquery 删除table行,该如何解决

标签:color   解决方案   span   class   api   com   tab   style   删除   

原文地址:http://www.cnblogs.com/shiyh/p/6971228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!