jQueryオブジェクト04



フェードアニメーション - fadeIn/fadeOut



ソースコード【 HTML 】

<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title>フェードアニメーション - fadeIn/fadeOut</title>

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>

<style>
body {
background-color: #F93;
}
	
#div1 {
width: 300px;
height: 300px;
background-color: #03F;
}

#div2 {		
width: 300px;
height: 300px;
background-color: #6CF;
}
</style>
</head>
<body>

<div class="container">
<div id="div1">fadeIn example.</div>
<div id="div2">fadeOut example.</div>
</div>

<script>
$(function() {
$('#div1').hide();	
$('#div1').fadeIn("slow");
$('#div2').fadeOut("slow");
})
</script>
</body>
</html>


ブラウザで表示【 Chrome

  • ロード時[ fadeIn ],[ fadeOut ]が実行される