js函數 盒子連續運動

<!DOCTYPE html>

<html lang="en">

 

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Document</title>

<style>

#box {

position: relative;

left: 200px;

top: 100px;

width: 50px;

height: 50px;

background-color: rgb(125, 240, 115);

}

</style>

</head>

 

<body>

<button>開始</button>

<div id="box">

 

</div>

<script src="./tools.js"></script>

<script>

var oBox = getById('box');

var btn = getByTag('button')[0];

 

btn.onclick = function () {

move(oBox, 'left', 10, 600, function () {

move(oBox, 'top', 10, 500, function () {

move(oBox, 'left', 10, 200, function () {

move(oBox, 'top', 10, 100);

});

});

});

}

 

</script>

</body>

 

</html>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章