老师,为什么我写的不生效?

来源:3-13 编程练习

weixin_慕雪1363253

2021-01-11 17:19:09

<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+=this.content;
},1000)
}
},
stop: function () {
在此补充代码
stopBtn.onclick=()=>{
clearInterval(this.timer)
}

}
}
// 在此补充代码
show.start();
show.stop();
</script>


写回答

1回答

好帮手慕慕子

2021-01-11

同学你好,代码中存在的问题解答如下:

1、如下所示位置,中文没有添加注释,不符合语法

http://img.mukewang.com/climg/5ffc27d4099a4d4405450320.jpg

建议参考下图修改,使用//添加注释

http://img.mukewang.com/climg/5ffc27f509c912a505500208.jpg

2、innerHTML单词拼写错误,建议参考下图修改:

http://img.mukewang.com/climg/5ffc280a096a1acb05710216.jpg

祝学习愉快~

0

0 学习 · 15276 问题

查看课程