日期:2014-05-16 浏览次数:20378 次
<!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").click(function(){
$(".div").append(cj);
$(".div_btn").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>
</body>
</html>
var cj="<a class='div_c'></a>";
$(".div_btn").each(function(){
$(this).click(function(){
//var a = $(this).createElement('a');
//a.setAttribute("class","div_c");
$(this).closest('div').append(cj);
$(this).remove();
})
})