Home  >  Article  >  Web Front-end  >  超级简单的jquery操作表格方法_jquery

超级简单的jquery操作表格方法_jquery

WBOY
WBOYOriginal
2016-05-16 16:26:561302browse

本文实例讲述了超级简单的jquery操作表格方法。分享给大家供大家参考。具体实现方法如下:

利用jquery给指定的table添加一行、删除一行

复制代码 代码如下:








1 2 3
11 22 33





1 2 3



<script> //在id为test的table的最后增加一行<br /> function addtr(id){ tr_id = $("#test>tbody>tr:last").attr("id");<br /> tr_id++; //alert(tr_id);<br /> str = "<tr id = '"+tr_id+"'><td width='30%'>re1<td width='30%'>re2<td width='30%'>re3";<br /> $('#'+id).append(str); } //删除id为test的table的最后一行<br /> function deltr(id){ tr_id = $("#test>tbody>tr:last").attr("id"); $('#'+tr_id).remove();<br /> }<br /> </script>

 
jQuery动态添加删除表格的行和列
复制代码 代码如下:






Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn