复制以下代码查看效果
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
div:first-of-type{background:red;
width:66px;
height:66px;}
div:nth-of-type(2){
width:66px;
height:66px;
background: blue;
}
div:last-of-type{
width:66px;
height:66px;
background: yellow;
}
</style>
<script type="text/javascript" src="./jquery-3.4.1/jquery-3.4.1.js"></script>
</head>
<body>
<div id="a1"></div>
<div id="a2">
</div>
<div id="a3">
</div>
<button type="button">点我点我</button>
<script type="text/javascript">
$(function(){
$('button').click(function(){
$('#a1').fadeToggle();
})
})
/*fadeIn()用于淡入已隐藏的元素
fadeOut()用于淡出可见元素
fadeToggle 淡入淡出
fadeTo(speed,opacity,callback)
opacity透明度0-1之间*/
</script>
</body>
</html>