<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>45-jQuery淡入淡出动画</title>
<style>
*{
margin: 0;
padding: 0;
}
div{
width: 300px;
height: 300px;
background: red;
display: none;
}
</style>
<script src="js/jquery-1.9.1.min.js"></script>
<script>
$(function () {
function btn0(){
$("div").fadeIn(1000,function () {
alert("淡入完毕!");
});
}
function btn1(){
$("div").fadeOut(1000,function () {
alert("淡出完毕!");
});
}
function btn2(){
$("div").fadeToggle(1000,function () {
alert("切换完毕!");
});
}
function btn3(){
$("div").fadeTo(1000,0.5,function () {
alert("淡入到完毕!");
});
}
$("button").eq(0).click(btn0);
$("button").eq(1).click(btn1);
$("button").eq(2).click(btn2);
$("button").eq(3).click(btn3);
});
</script>
</head>
<body>
<button>淡入</button>
<button>淡出</button>
<button>切换</button>
<button>淡入到</button>
<div></div>
</body>
</html>