fadeToggle:可以在fadeIn与fadeOut之间来回切换
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js" type="text/javascript" charset="utf-8"></script>
<body>
<div id="id1">
</div>
<button type="button" name="one">点我生成</button>
<button type="button" name="two">淡入淡出</button>
<script type="text/javascript">
$(document).ready(function(){
$('button[name = one]').click(function(){
$('#id1').css({'width':'100px','height':'100px','background':'red'});
});
$('button[name = two]').click(function(){
//可以进行淡入淡出之间切换参数为毫秒
$('#id1').fadeToggle(2000);
})
})
</script>
</body>
</html>