Love beautiful code? We do too.
.fadeIn(): Hiển thị các thành phần phù hợp với hiệu ứng rõ dần (fade in).
Đã được thêm vào từ phiên bản 1.0
.fadeIn(Độ bền)
Độ bền có thể bằng số hoặc bằng chữ: slow, fast.
$('p').fadeIn(300);
$('p').fadeIn('fast');
.fadeIn(Độ bền,function(){...})
Độ bền có thể bằng số hoặc bằng chữ: slow, fast.
$('p').fadeIn(300,function(){
$('span').fadeIn(100);
});
Đã được thêm vào từ phiên bản 1.4.3
.fadeIn(Độ bền,'easing',function(){...})
Độ bền có thể bằng số hoặc bằng chữ: slow, fast.
Easing có thể sử dụng swing hoặc linear
$('p').fadeIn(300,'swing',function(){
$('span').fadeIn(100);
});
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
background-color: blue;
display: none;
float: left;
margin-right: 20px;
height: 100px;
width: 100px;
}
p {
clear: both;
}
</style>
<script>
$(function(){
$('button').click(function(){
$('.test03').fadeIn(2000);
$('.test02').fadeIn('slow');
$('.test01').fadeIn();
});
});
</script>
</head>
<body>
<p><button>Click</button></p>
<div class="test03">fadeIn(2000)</div>
<div class="test02">fadeIn('slow')</div>
<div class="test01">fadeIn()</div>
</body>
</html>
Click vào button để thấy hiệu ứng.
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
background-color: blue;
display: none;
float: left;
margin-right: 20px;
height: 100px;
width: 100px;
}
p {
clear: both;
}
</style>
<script>
$(function(){
$('button').click(function(){
$('div').fadeIn(2000,function(){
$(this).css('background-color','red');
});
});
});
</script>
</head>
<body>
<p><button>Click</button></p>
<div>Thành phần div</div>
</body>
</html>
Hiển thị trình duyệt:
Click vào button để thấy hiệu ứng, sau khi hoàn thành hiệu ứng sẽ hiển thị nội dung bên trong function.
Html viết:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tiêu đề</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<style>
div {
background-color: blue;
display: none;
float: left;
margin-right: 20px;
height: 100px;
width: 100px;
}
p {
clear: both;
}
</style>
<script>
$(function(){
$('button').click(function(){
$('.swing').fadeIn(2000,'swing',function(){
$(this).css('background-color','red');
});
$('.linear').fadeIn(2000,'linear',function(){
$(this).css('background-color','red');
});
});
});
</script>
</head>
<body>
<p><button>Click</button></p>
<div class="swing">fadeIn swing</div>
<div class="linear">fadeIn linear</div>
</body>
</html>
Hiển thị trình duyệt:
Click vào button để thấy hiệu ứng, sau khi hoàn thành hiệu ứng sẽ hiển thị nội dung bên trong function.
Hoclaptrinh.vn © 2017
From Coder With
Unpublished comment
Viết câu trả lời