老师,请帮忙检查一下代码,谢谢
来源:3-13 编程练习
廖可爱bongbong
2021-06-20 21:40:04
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>箭头函数的应用</title>
<style>
div {
width: 320px;
margin: 20px 0;
line-height: 30px;
background: yellowgreen;
}
</style>
</head>
<body>
<button id="start">开始</button>
<button id="stop">停止</button>
<div id="box"></div>
<script>
const startBtn = document.getElementById('start')
const stopBtn = document.getElementById('stop')
const box = document.getElementById('box')
var show = {
content: "Hello World",
timer: null,
start: function () {
// 在此补充代码
startBtn.onclick = () => {
this.timer = setInterval(() => {
box.innerHTML += (show.content) + ' ' + ' ';
}, 1000);
}
},
stop: function () {
// 在此补充代码
stopBtn.onclick = () => {
clearInterval(this.timer)
}
},
}
// 在此补充代码
show.start();
show.stop();
</script>
</body>
</html>
1回答
好帮手慕言
2021-06-21
同学你好,效果是正确的,继续加油,祝学习愉快~
相似问题