jquery兑现动态添加一行,删除一行
jquery实现动态添加一行,删除一行。
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jane shopping</title>
<script src="scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#newBtn").bind("click", function(){
//alert($("input:checked"));
$("#myTable").append("<tr><td><input id=\"sd\" type=\"checkbox\" /></td><td><input type=\"text\" /></td></tr>");
// alert(document.getElementById('sd').value);
});
$("#delBtn").bind("click", function(){
//alert($("input:checked"));
$("input:checked").parent().parent().remove();
});
});
</script>
</head>
<body>
<table id="myTable">
<tr><td><input id="sd" type="checkbox" /></td><td><input type="text" /></td></tr>
</table>
<input type="button" value="add" id="newBtn"/>
<input type="button" value="del" id="delBtn"/>
</body>
</html>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Jane shopping</title>
<script src="scripts/jquery-1.3.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#newBtn").bind("click", function(){
//alert($("input:checked"));
$("#myTable").append("<tr><td><input id=\"sd\" type=\"checkbox\" /></td><td><input type=\"text\" /></td></tr>");
// alert(document.getElementById('sd').value);
});
$("#delBtn").bind("click", function(){
//alert($("input:checked"));
$("input:checked").parent().parent().remove();
});
});
</script>
</head>
<body>
<table id="myTable">
<tr><td><input id="sd" type="checkbox" /></td><td><input type="text" /></td></tr>
</table>
<input type="button" value="add" id="newBtn"/>
<input type="button" value="del" id="delBtn"/>
</body>
</html>