<!DOCTYPE html>
<html>
<head>
<title>Chạy thử Code Hàm clearTimeout() trong JavaScript</title>
</head>
<body>
<h1>Chạy thử Code Hàm clearTimeout() trong JavaScript</h1>
<p>Dùng để hủy chức năng hẹn giờ của hàm setTimeout bằng cách đưa biến của hàm setTimeout vào:</p>
<script>
function loiChao() {
alert("Xin chào!");
}
// Đặt biến chứa hàm hẹn giờ
var biento = setTimeout(loiChao, 3000);
// Đưa biến hàm hẹn giờ vào
clearTimeout(biento);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Chạy thử Code Hàm clearTimeout() trong JavaScript</title>
</head>
<body>
<h1>Chạy thử Code Hàm clearTimeout() trong JavaScript</h1>
<p>Dùng để hủy chức năng hẹn giờ của hàm setTimeout bằng cách đưa biến của hàm setTimeout vào:</p>
<script>
function loiChao() {
alert("Xin chào!");
}
// Đặt biến chứa hàm hẹn giờ
var biento = setTimeout(loiChao, 3000);
// Đưa biến hàm hẹn giờ vào
clearTimeout(biento);
</script>
</body>
</html>