您的位置:首页 > Web前端 > JQuery

jquery淡入淡出无延迟代码

2013-12-28 17:22 417 查看
<!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 }); }

也可以。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: