JQ remove()方法实现似收货地址逐一删除的效果

时间:2021-10-10 09:22:32
<!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>
</head>
<style type="text/css">
.box{width:100%;background:pink;height:40px;color:green;line-height:40px;margin-bottom:20px;}
.fc{clear:both;}
.fl{float:left;padding-left:30px;}
.fr{float:right;color:red;padding-right:30px;cursor:pointer}
</style>
<body>
<div class="box">
<div class="fc">
<div class="fl">我怀念的,是无话不说</div>
<div class="fr del">删除</div>
</div>
</div>
<div class="box">
<div class="fc">
<div class="fl">我怀念的,是无话不说</div>
<div class="fr del">删除</div>
</div>
</div>
<div class="box">
<div class="fc">
<div class="fl">我怀念的,是无话不说</div>
<div class="fr del">删除</div>
</div>
</div><div class="box">
<div class="fc">
<div class="fl">我怀念的,是无话不说</div>
<div class="fr del">删除</div>
</div>
</div>
<div class="box">
<div class="fc">
<div class="fl">我怀念的,是无话不说</div>
<div class="fr del">删除</div>
</div>
</div> </body>
<script type="text/javascript" src="js/jQuery1.7.js"></script>
<script>
$(document).ready(function(){
$(".del").click(function(){
$(this).parents(".box").remove();
}) })
</script> </html>