码迷,mamicode.com
首页 > 其他好文 > 详细

在一个table中动态添加一行或删除一行

时间:2017-07-05 10:05:22      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:table 添加一行

	
	<table id="selected_user_table" width="100%" >
		<thead>
			<tr><th class="center" colspan="2"  style="background-color:#F2F2F2;height:20px;">已选择</th></tr>
		</thead>
		<tbody id="select_user_td">
		</tbody>
	</table>
<script>
//添加一行
	var trHTML = "<tr id=‘tr_"+row.id+"‘><td width=‘10%‘><input  name=‘selected_user‘ type=‘checkbox‘/></td></tr>"
	if(isOder){
		$("#select_user_td tr:eq("+num+")").after(trHTML); 
	}else{
		$("#select_user_td").append(trHTML);
	}
	
	//删除一行
	$("#tr_"+row.id).remove();//选中tr,然后删除。
</script>


本文出自 “JianBo” 博客,转载请与作者联系!

在一个table中动态添加一行或删除一行

标签:table 添加一行

原文地址:http://jianboli.blog.51cto.com/12075002/1944580

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