老师 帮忙检查下(输出有点问题)

来源:3-13 编程练习

lcy_18

2021-07-24 10:51:31

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title>Document</title>

    <style>

        div {

            width: 300px;

            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=()=>{

                clearInterval(this.timer);

                this.timer=setInterval(()=>{

//              console.log(this);

                box.innerHTML+=this.content;

            },1000);

                }

                

            },

            stop:  function(){

                // 在此补充代码

                stopBtn.onclick=()=>{

//              console.log(this);

                clearInterval(this.timer);

                }

                

            },

        }

         // 在此补充代码

         show.start();

         show.stop();

    </script>

</body>

</html>


写回答

1回答

好帮手慕言

2021-07-24

同学你好,效果是对的,另外:输出有点问题是指单词之前挨的太近了吗?

http://img.mukewang.com/climg/60fba0d909ac10a102280113.jpg

如果是的话,可以在单词之间添加空格,例如:

http://img.mukewang.com/climg/60fba1450935803606460214.jpg

如果不是上述问题,可以详细描述下,老师帮助再帮助解答。

祝学习愉快~

0

0 学习 · 15276 问题

查看课程