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

为什么动不了啊

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>xxxx</title>
<style type="text/css">
body{
	margin:0;padding: 0;
}
#dds{
	width: 400px;
	height: 400px;
	position: relative;
	background-color: yellow;
	left: -400px;
}
#dd{
	background-color: blue;
	height: 50px;
	width: 50px;
	position: absolute;
	left: 400px;
	top: 175px;
}
</style>
<script type="text/javascript">
	window.onload=function () {
		var odiv=document.getElementById('dds');
		odiv.ommouseover = function(){
			startMove(400);
		}
		odiv.ommouseout = function(){
			startMove(0);
		}
	}
	var timer = null;
	function startMove(itarget){
		clearInterval(timer);
		var odiv = document.getElementById('dds');
		timer = setInterval(function(){
			var speed=0;
			if (odiv.offsetLeft>itarget) {
					speed=-10;
				}
			else{
					speed=10;
				}
			if (odiv.offsetLeft==itarget) {
				clearInterval(timer);
			}
			else{
				odiv.style.left=odiv.offsetLeft+speed+'px';
			}
		},30)
	}
</script>

</head>
<body>
	<div id='dds'>
		<span id='dd'>分享</span>
	</div>
</body>
</html>


正在回答

2 回答

你的onmouseover 和 onmouseout 写错啦

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

DDjx 提问者

对不起,我是一个逗比- -0
2015-12-07 回复 有任何疑惑可以回复我~
#2

木子舟义 回复 DDjx 提问者

哈哈哈哈 加油~
2015-12-07 回复 有任何疑惑可以回复我~

你的onmouse写错了

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

举报

0/150
提交
取消
JS动画效果
  • 参与学习       113910    人
  • 解答问题       1502    个

通过本课程JS动画的学习,从简单动画开始,逐步深入各种动画框架封装

进入课程

为什么动不了啊

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号