一.
通过 jQuery,可以实现元素的淡入淡出效果
1.fadeIn() 淡入方法
<body>
<button>点击这里,使三个圆形淡入</button>
<br><br>
<div id="div1" style="width:40px;height:40px;display:none;background-color:red;border-radius:50%;"></div>
<br>
<div id="div2" style="width:40px;height:40px;display:none;background-color:green;border-radius:50%;"></div>
<br>
<div id="div3" style="width:40px;height:40px;display:none;background-color:blue;;border-radius:50%;"></div>
</body>
引入插件并写入下面代码则出现效果
<script src="../jquery/jquery-1.11.1.min.js" ></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
});
</script>
2.fadeout() 淡出方法
相反代码和上面一样写的基本一样,把fadeIn换成fadeout。两者都可取值slow"、"fast’'指效果时长
$("button").click(function(){
$("#div1").fadeOut();
$("#div2").fadeOut("slow");
$("#div3").fadeOut(3000);
});
注释:可举一反三