日期:2014-05-16  浏览次数:20476 次

动态增加div问题
<div id=aaa>
<div class=bbb>1</div>
<div class=bbb>2</div>
<div class=bbb>3</div>
<div class=bbb>4</div>
</div>

把第二个或者第三个div完整复制并插到最后一个div后面,jquery该怎么写?
得出下面的结果

<div id=aaa>
<div class=bbb>1</div>
<div class=bbb>2</div>
<div class=bbb>3</div>
<div class=bbb>4</div>
<div class=bbb>2</div>
</div>

------解决方案--------------------
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#aaa div:nth-child(3)").clone().appendTo("#aaa")
});
</script>
<div id=aaa>
<div class=bbb>1</div>
<div class=c>2</div>
<div class=bbb>3</div>
<div class=bbb>4</div>
</div>
</head>
<body>
</body>
</html>