87,910
社区成员
发帖
与我相关
我的任务
分享
$(document).ready(function(){
$("#addOne").click(function(){
$(this).parent().parent().clone(true).appendTo($(".foo")[$(".foo").length-1]);
});
$("#addTwo").click(function(){
$(this).parent().parent().clone(true).appendTo($(".foo2")[$(".foo2").length-1]);
});
});
<form name="fm" action="" method="post" enctype="multipart/form-data">
<table width="100%">
<%
Iterator it = collection.iterator();
int i=1;
while(it.hasNext()){
Cc_action_prologueDto firstFloor=(Cc_action_prologueDto)it.next();
%>
<tr class="foo">
<td width="5%" height="100%" valign="middle">
<%if(i<4){%>
<%=i %>
<%} %>
</td>
<td width="5%" height="100%" valign="middle">
描述
</td>
<td width="30%" height="100%" valign="middle">
<input type="text" style="width:80%" name="giftName" id="giftName" value="<%=firstFloor.getNodename() %>" maxlength="50">
</td>
<%if(i>2){%>
<td>
<input type="button" class="button" value="条件" onClick="save()"/>
</td>
<%} %>
</tr>
<%
Iterator it2 = firstFloor.getCollecion().iterator();
int j=1;
while(it2.hasNext()){
Cc_action_prologueDto sedFloor=(Cc_action_prologueDto)it2.next();
%>
<!--
<tr id="sed" class="foo2">
<td width="5%" height="100%" valign="middle">
</td>
<td width="5%" height="100%" valign="middle">
<%if(j==1) {%>
选项
<%} %>
</td>
<td width="30%" height="100%" valign="middle">
<%=j %>
<input type="text" style="width:40%" name="giftName" id="giftName" value="<%=sedFloor.getNodename() %>" maxlength="8">
<input type="text" style="width:40%" name="giftName" id="giftName" value="<%=sedFloor.getNodevalue() %>" maxlength="8">
</td>
<%if(j==1) {%>
<td colspan="8"><input type="button" id="addOne" value="+"/></td>
<%}else{%>
<td width="30%" height="100%" valign="middle">
<input type="text" style="width:40%" name="giftName" id="giftName" value="<%=sedFloor.getResultid() %>" maxlength="8">
<input type="button" id="adddelete" onclick="adddelete()" id="delete" value="-"><input type="button" id="addTwo" onclick="addRow()" value="+"/>
</td>
<%}%>
</tr>
<%} %>
<%
j++;
}
%>
<%
i++;
}
%>
</table>
<!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>无标题文档</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#inner1").click(function(){
$(this).parent().parent().clone(true).appendTo($(this).parent().parent());
});
$("#inner2").click(function(){
$(this).parent().parent().clone(true).attr("id","parent3").appendTo($(this).parent().parent());
alert($("#parent3").html());
});
});
</script>
<style>
.parent1{
border:#000000 1px solid;
margin:10px;
}
.parent2{
border:#0000FF 1px solid;
margin:10px;
}
.inner1{
border:#990000 1px solid;
margin:10px;
}
#parent3{
background:#99CCFF;
}
</style>
</head>
<div id="parent1" class="parent1">
<div id="parent2" class="parent2">
<div id="inner1" class="inner1">
inner1
</div>
<div id="inner2" class="inner1">
inner2
</div>
</div>
</div>
<body>
</body>
</html>
var clone = $(this).parent().parent().clone(true);
clone.appendTo($("table"));
$($(".foo")[$(".foo").length-1]).after(clone);