jquery淡入淡出fadeIn() fadeOut()

<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#button1").click(function(){
$("#div1").fadeIn();
$("#div2").fadeIn("slow");
$("#div3").fadeIn(3000);
});
$("#button2").click(function(){
$("#div1").fadeOut(3000);
$("#div2").fadeOut(2000);
$("#div3").fadeOut(1000);
});
});
</script>
</head>


<body>
<p>演示带有不同参数的fadeIn()方法</p>
<button id="button1">点击这里,使三个矩形淡入</button>
<button id="button2">点击这里,使三个矩形淡出</button><br /><br /><br /><br />
<div id="div1" style="width:80px;height:80px;display:none;background-color:red;"></div>
<div id="div2" style="width:80px;height:80px;display:none;background-color:green;"></div>
<div id="div3" style="width:80px;height:80px;display:none;background-color:blue;"></div>
</body>

</html>



<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("div").fadeToggle("1000")   //褪色开关
});
});
</script>
</head>
<body>
<p>演示点击图片图片淡入淡出</p>
<button>点我淡入淡出</button><br /><br />
<div style="width:80px;height:80px;background-color:red;"></div>
</body>
</html>


<!DOCTYPE html>
<html>
<head>
<script src="jquery.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("#div1").fadeTo("1000",0.1);
$("#div2").fadeTo("slow",0.5);
$("#div3").fadeTo("slow",0.5);
$("div").fadeTo("slow",1)//还原到1
});
});
</script>
</head>
<body>
<p>演示不同参数fadeTo()方法</p>
<button>点我淡入淡出</button><br /><br />
<div id="div1" style="width:80px;height:80px;background-color:red;"></div>
<div id="div2" style="width:80px;height:80px;background-color:green;"></div>
<div id="div3" style="width:80px;height:80px;background-color:blue;"></div>
</body>
</html>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

jony0303

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值