<!DOCTYPE html>
<html>
<head>
<meta charset = "utf-8">
<title></title>
<script type="text/javascript">
window.onload = function(){
var div = document.getElementById('div');
var img = div.getElementsByTagName('img');
var ten = 10;
var input = document.getElementById('input');
input.onclick = function(){
setInterval(function(){
var left = parseInt(img[0].marginLeft);
left += ten + 'px';
},100)
}
}
</script>
<style>
#div{width:1000px; background: gray; display: block;position: absolute;}
img{width: 100px;height: 100px; display: block;position: relative;}
input{margin-top:100px;}
</style>
</head>
<body>
<div id="div">
<img src="C:\Users\Administrator\Pictures\51607230_p0.png">
</div>
<input type="button" value="click" id="input">
</body>
</html>
(不要在意图片),为什么点了Input 图不动?
pardon110
相关分类