<div class="codetitle"> <span><a style="CURSOR: pointer" data="78829" class="copybut" id="copybut78829" onclick="doCopy('code78829')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code78829"> <br> <br> <br><title> <br> </title> <br><script src="js/jquery-1.4.2_min.js" type="text/javascript"></script> <br><script type="text/javascript" language="javascript"> <BR>var row_count = 0; <BR>function addNew() <BR>{ <BR>var table1 = $('#table1'); <BR>var firstTr = table1.find('tbody>tr:first'); <BR>var row = $("<tr>"); <BR>var td = $("<td>"); <BR>td.append($("<input type='checkbox' name='count' value='New'><b>CheckBox"+row_count+"") <BR>); <BR>row.append(td); <BR>table1.append(row); <BR>row_count++; <BR>} <BR>function del() <BR>{ <BR>var checked = $("input[type='checkbox'][name='count']"); <BR>$(checked).each(function(){ <BR>if($(this).attr("checked")==true) //注意:此处判断不能用$(this).attr("checked")==‘true'来判断。 <BR>{ <BR>$(this).parent().parent().remove(); <BR>} <BR>}); <BR>} <BR></script> <br> <br> <br><input type="button" value="Add" onclick="addNew();"> <br><input type="button" value="Delete" onclick="del();"> <br><div id="rightcontent"> <br><table id="table1" cellspacing="3" cellpadding="3" border="1"> <br><tbody> <br><tr> <br><th> <br>Add new row,then test the delete function. <br> </th> <br> </tr> <br> </tbody> <br> </table> <br> </div> <br> <br><br> </div>