为了账号安全,请及时绑定邮箱和手机立即绑定

我什么我打开直接就收回去了,是代码有问题吗????求大佬看下

<style type="text/css">

            *{

                margin: 0;

                padding: 0;

            }

            #box1{

                width: 200px;

                height: 200px;

                background: red;

                position: relative;

                left: -200px;

                top: 0;

            }

            #span{

                width: 20px;

                height: 50px;

                background-color: #bfa;

                position: absolute;

                left: 200px;

                top: 75px;

            }

        </style>

        <script  type="text/javascript">

            window.onload = function(){

                var box1 = document.getElementById("box1");

                box1.onmouseenter = function(){

                    startMove();

                }

                box1.onmouseout = function(){

                    startMove2();

                }

            }

            var timer = null;

            function startMove(){

                clearInterval(timer);

                timer = setInterval(function(){

                    if(box1.offsetLeft == 0){

                        clearInterval(timer);

                    }

                    else{

                        box1.style.left = box1.offsetLeft + 10 + "px";

                    }

                },30);

            };

            function startMove2(){

                clearInterval(timer);

                timer = setInterval(function(){

                    if(box1.offsetLeft == -200){

                        clearInterval(timer);

                    }

                    else{

                        box1.style.left = box1.offsetLeft - 10 + "px";

                    }

                },30);

            };

        </script>

    </head>

    <body>

        <div id="box1"><span id="span">分享</span></div>

    </body>


正在回答

1 回答

 box1.onmouseover = function () {

            startMove();

        }

你单词拼错了

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

我什么我打开直接就收回去了,是代码有问题吗????求大佬看下

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信