刚开始two是隐藏的,点击one对应的two会显示,第一次点击two的时候,只会跳出一个alert(),重复点击就会递增的alrt(), 2次,3次......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
.one {
height: 100px;
border-bottom: 1px solid #000;
}
.two {
display: none;
width: 50px;
height: 20px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<div class="box">
<div class="box-item">
<div class="one">
one
<div class="two">two</div>
</div>
</div>
<div class="box-item">
<div class="one">
one
<div class="two">two</div>
</div>
</div>
<div class="box-item">
<div class="one">
one
<div class="two">two</div>
</div>
</div>
</div>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<script>
$('.box .box-item .one').click(function() {
$(this).find(".two").show()
$(this).find(".two").click(function() {
alert($(this).html());
})
})
</script>
</body>
</html>
侃侃尔雅
动漫人物
开心每一天1111