移動端事件

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>Title</title>    <style>        *{            margin:0;            padding:0;        }        ul{            list-style: none;        }        #box{            width:200px;            height: 200px;            font-weight:bold;">#999;        }    </style></head><body>    <div id="box">    </div>        <script>             var box = document.querySelector('#box')             box.addEventListener('touchstart',function(){                box.style.backgroundColor = 'red'             })             box.addEventListener('touchmove',function(){                 box.style.backgroundColor = 'yellow'                 box.innerHTML = Math.random()             })             box.addEventListener('touchend',function(){                 box.style.backgroundColor = 'blue'             })             box.addEventListener('touchcancel',function(){                 box.style.backgroundColor = 'pink'             })            setTimeout(function(){                    alert('恭喜你中獎了')            },3000)        </script></body></html>
相關文章
相關標籤/搜索