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

怎么返回当前已经移除的元素

<!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://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  var cj="<a class='div_c'></a>";
   $(".div_btn").each(function(){
           $(this).click(function(){
  
               $(this).closest('div').append(cj);
               $(this).remove();
           })
    })

});
</script>
<style type="text/css">
*{
margin:0;
padding:0;
}
.div{
width:300px;
height:200px;
border:1px solid #DCDCDC;
float:left;
position:relative;
}
.div_btn{
width:70px;
height:30px;
background:#00BCF3;
float:right;
margin:150px 20px 0 0;
line-height:30px;
text-align:center;
color:#FFF;
}
.div_c{
width:70px;
height:30px;
background:#00BCF3;
position:absolute;
top:10px;
right:10px;
}
</style>
</head>

<body>
<div class="div">

<a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">

<a href="javascript:;" class="div_btn">点击</a>
</div>
<div class="div">

<a href="javascript:;" class="div_btn">点击</a>
</div>

</body>
</html>


请问下 当我点击".div_btn"的时候 创建了".div_c"  当点击创建".div_c" 还原".div_btn" 
还有就是在点击其他的".div_btn"的时候 已经创建了的".div_c" 也要还原回去请问下 应该怎么做啊 
------解决方案--------------------
<!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://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){

var cj='<a onclick="javascript:hide(this);" class="div_c" href="#">点击</a>';
   $(".div_btn").each(function(){
           $(this).click(function(){
   
               $(this).closest('div').append(cj);
               
               $(this).closest('div').siblings('.div').find(".div_c:visible"