<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="../../jquery-3.4.1.min.js"></script>
<style>
.div{
width: 200px;
height: 200px;
border: 2px solid #333333;
display:inline-block;
margin: 10px;
}
</style>
</head>
<body>
<button dry="div_panel1" class="panel1">one</button>
<button dry="div_panel2" class="panel2">two</button>
<button dry="div_panel3" class="panel3">three</button>
<button dry="div_panel4" class="panel4">four</button>
<br>
<div class="div div_panel1">one</div>
<div class="div div_panel2">two<</div>
<div class="div div_panel3">three</div>
<div class="div div_panel4">four</div>
<script>
$(function () {
$('button').on('click',function () {
let divId = $(this).attr('dry');
$('.'+divId).slideToggle();
})
})
</script>
</body>
</html>
JQuery动态dry获取元素并设置对象样式
猜你喜欢
转载自blog.csdn.net/printf_hello/article/details/104027035
今日推荐
周排行