Love beautiful code? We do too.
.delay(): Thiết lập một bộ đếm thời gian để trì hoãn thực hiện các hạng mục tiếp theo trong các hành động.
Đã được thêm vào từ phiên bản 1.4
.delay(độ bền)
------------------------------------------------------------------------------------------------------------------
$('p').slideUp(200).delay(1000).fadeIn(400);
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>
p {
background: blue;
}
</style>
<script>
$(function(){
$('button').click(function() {
$('p.first').slideUp(300).delay(2000).fadeIn(400);
$('p.second').slideUp(300).fadeIn(400);
});
});
</script>
</head>
<body>
<button>Run</button>
<p class="first">có delay</p>
<p class="second">không delay</p>
</body>
</html>
Hiển thị trình duyệt:
Ta thấy thành phần có sử dụng delay đã được trì hoãn 2 giây (delay(2000)) so với thành phần không có sử dụng delay.
Hoclaptrinh.vn © 2017
From Coder With
Unpublished comment
Viết câu trả lời