jquery淡入淡出无延迟代码

本文介绍了如何使用jQuery库实现网页中按钮触发下三个矩形元素的淡入淡出动画效果,包括引入jQuery库、事件监听、CSS动画应用等关键步骤。
<!DOCTYPE html>

<html>

<head>

<script src="jquery.js"></script>

<script>

$(document).ready(function(){

  $("#button1").mouseover(function(){

       $(".div1").stop().animate({opacity:1},1000);

    $(".div2").stop().animate({opacity:1},1000);

    $(".div3").stop().animate({opacity:1},1000);

  });

 

  $("#button1").mouseleave(function(){

       $(".div1").stop().animate({opacity:0},1000);

    $(".div2").stop().animate({opacity:0},1000);

    $(".div3").stop().animate({opacity:0},1000);

  });

 

});

</script>

</head>

 

<body>

<button id="button1">鼠标放在这里,使三个矩形淡入</button>

 

<div class="div1" style="width:80px;height:80px;opacity:0;background-color:red;"></div>

<br>

 

<div class="div2" style="width:80px;height:80px;opacity:0;background-color:green;"></div>

<br>

 

<div class="div3" style="width:80px;height:80px;opacity:0;background-color:blue;"></div>

</body>

</html>

 

另外

function () { $(".div1").animate({ 'opacity': 0 },{ queue: false, duration: 1000 }); },


function () { $(".div1").animate({ 'opacity': 1 }, { queue: false, duration: 1000 }); } 

也可以。

 

转载于:https://www.cnblogs.com/flying607/p/3495569.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值