<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jq Rows.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#but_add").click(function(){
var col = $("#tab").find("tr").eq(1).clone();
col.appendTo("#tab");
});
$("#but_del").click(function(){//删除事件
这里如何写删除行代码
//$("#tab tr:gt(0)").each(function(){ });
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table border="0" cellpadding="0" cellspacing="0" id="tab1" align="center" width="25%" bgcolor="#CCCCCC">
<tr>
<td></td>
<td style="text-align:right"><input type="button" id="but_add" value="添加" />
<input type="button" id="but_del" value="删除" /></td>
</tr></table>
<table border="1" cellpadding="2" cellspacing="0" id="tab" align="center" width="25%">
<tr>
<td><input type="checkbox" id="ck" /></td>
<td style="text-align:center">序号</td>
<td style="text-align:center">内容</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td><input type="text" value=""/></td>
<td><input type="text" id="txt_but1" /></td>
</tr>
</table>
</form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#but_add").click(function(){
var col = $("#tab").find("tr").eq(1).clone();
col.appendTo("#tab");
});
$("#but_del").click(function(){//删除事件
这里如何写删除行代码
//$("#tab tr:gt(0)").each(function(){ });
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<table border="0" cellpadding="0" cellspacing="0" id="tab1" align="center" width="25%" bgcolor="#CCCCCC">
<tr>
<td></td>
<td style="text-align:right"><input type="button" id="but_add" value="添加" />
<input type="button" id="but_del" value="删除" /></td>
</tr></table>
<table border="1" cellpadding="2" cellspacing="0" id="tab" align="center" width="25%">
<tr>
<td><input type="checkbox" id="ck" /></td>
<td style="text-align:center">序号</td>
<td style="text-align:center">内容</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td><input type="text" value=""/></td>
<td><input type="text" id="txt_but1" /></td>
</tr>
</table>
</form>
</body>
</html>
解决方案 »
- asp.net如何接收jquery传过来的json格式的参数
- jquery ajax 一个简单实例问题
- 用文本代替没有图片
- 请milo4210(米罗)大哥进?
- 让人头疼的问题
- 系统时间被修改了,杀毒软件不能用,谁能告诉我怎么解决啊?
- 一个带时间选择功能的日期控件
- 请教一个效率问题.
- 在Global的Application_Error方法中怎么给其他页面传递对象?
- 程序集“Lodb.SQLServerDAL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null”中的类型“Lodb.SQLServerDAL.ProductsDAL”的方法“GetKey
- 问个数据库的问题
- 一个JS调用后台传值方法的问题!
$('#tb_commodity').append(
"<tr><td><input type='text' size='20'/></td><td><button name='btn_add' onclick='delRow(this)'"+
" class='bt1_mouseout' onmouseover='this.className=\"bt1_mouseover\"' onmouseout='this.className=\"bt1_mouseout\"'>删除</button></td></tr>");
}
function delRow(a){
alert($(a).get(0));
$(a).parent().parent().remove();
}
然后再执行删除的动作
function Deletetr() {
var cbs = $('#tab input:[type="checkbox"]');
cbs.each(function() {
$cb = $(this);
if ($cb.attr("checked") == true)
$cb.parent("td").parent("tr").remove();
});
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<script src="jquery-1.3.2-vsdoc.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$("#but_del").click(function() {
$("input[name='checkbox']:checked").each(function() { $(this).parent().parent().remove();
})
}); });
</script>
</head>
<body>
<form id="form1" name="form1" method="get" runat="server">
<table border="0" cellpadding="0" cellspacing="0" id="tab1" align="center" width="25%" bgcolor="#CCCCCC">
<tr>
<td></td>
<td style="text-align:right"><input type="button" id="but_add" value="添加" />
<input type="button" id="but_del" value="删除" /></td>
</tr></table>
<table border="1" cellpadding="2" cellspacing="0" id="tab" align="center" width="25%">
<tr>
<td><input type="checkbox" name="checkbox" /></td>
<td style="text-align:center">序号</td>
<td style="text-align:center">内容</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" /></td>
<td><input type="text" value=""/></td>
<td><input type="text" id="txt_but1" /></td>
</tr>
</table> </form>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" >
<title>表单删除</title>
<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#but_add").click(function(){
var col = $("#tab").find("tr").eq(1).clone();
col.appendTo("#tab");
});
$("#but_del").click(function(){//删除事件
$("input[type='checkbox']:checked").each(
function() {
$(this).parent("td").parent("tr").remove();
}
)
});
});
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" id="tab1" align="center" width="25%" bgcolor="#CCCCCC">
<tr>
<td></td>
<td style="text-align:right">
<input type="button" id="but_add" value="添加" />
<input type="button" id="but_del" value="删除" />
</td>
</tr>
</table>
<table border="1" cellpadding="2" cellspacing="0" id="tab" align="center" width="25%">
<tr>
<td>
<input type="checkbox" id="ck" onlick=""/>
</td>
<td style="text-align:center">序号</td>
<td style="text-align:center">内容</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td><input type="text" value=""/></td>
<td><input type="text" id="txt_but1" /></td>
</tr>
</table>
</body>
</html>