01-window对象
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>window对象</title>
<style>
div {
height: 3000px;
}
</style>
</head>
<body>
<div>
</div>
<script>
window.document.querySelector('div');
window.addEventListener('scroll', function() {
})
window.prompt;
console.log(window);
</script>
</body>
</html>
02-延迟函数setTimeout()定时器
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>延迟函数setTimeout()定时器</title>
</head>
<body>
<button>解除定时器</button>
<script>
let btn = document.querySelector('button');
let timer = setTimeout(function() {
console.log(111);
}, 3000)
btn.addEventListener('click', function() {
clearTimeout(timer)
})
</script>
</body>
</html>
03-自动消失的广告案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
img {
position: absolute;
left: 0;
bottom: 0;
}
</style>
</head>
<body>
<img src="images/ad.png" alt="">
<script>
let img = document.querySelector('img');
setTimeout(function() {
img.style.display = 'none';
}, 5000)
</script>
</body>
</html>
效果展示
04-递归函数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
let num = 0;
function fn() {
num++;
console.log(11);;
if (num >= 100) {
return;
}
fn()
}
fn();
</script>
</body>
</html>
05-利用递归实现setInterval
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div></div>
<script