第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

錯在哪里?求大神幫忙!

<!DOCTYPE?html>
<html>
	<head>
		<meta?charset="UTF-8">
		<title></title>
		<style>
			*{
				margin:0;
				padding:0;
			}
			#div{
				width:200px;
				height:200px;
				background:red;
				position:relative;
				left:-200px;
				
			}
			#div?span{
				width:20px;
				height:50px;
				background:blue;
				position:absolute;
				left:200px;
				top:75px;
				color:white;
				padding-top:10px;
			}
		</style>
		<script>
			window.onload=function(){
				var?div=document.getElementById('div');
				
				div.onmouseover=function(){
					move(0);
				}
				div.onmouseout=function(){
					move(-200);
				}
			}
			
			var?div=document.getElementById('div');
				var?timer;
				function?move(iTarget){
					clearInterval(timer);
					timer=setInterval(function(){
						var?speed?=?(iTarget-div.offsetLeft)/20;
							speed?=?speed>0?math.ceil(speed):math.floor(speed);
						if(div.offsetLeft==iTarget){
							clearInterval(timer);
						}else{
							div.style.left=div.offsetLeft+speed+'px';
						}
						
					},30);
				}
				
			
		</script>
	</head>
	<body>
		<div?id="div">
			<span?id="share">分享</span>
		</div>
	</body>
</html>


正在回答

2 回答

1,var div=document.getElementById('div'); 放在move函數(shù)里面

2,math改成大寫 Math

????????<script>
????????????window.onload=function(){
????????????????var?div=document.getElementById('div');
?????????????????
????????????????div.onmouseover=function(){
????????????????????move(0);
????????????????}
????????????????div.onmouseout=function(){
????????????????????move(-200);
????????????????}
????????????}
?????????????
????????????var?timer;
????????????function?move(iTarget){
????????????	var?div=document.getElementById('div');
????????????????clearInterval(timer);
????????????????timer=setInterval(function(){
????????????????????var?speed?=?(iTarget-div.offsetLeft)/20;
????????????????????????speed?=?speed?>0???Math.ceil(speed):Math.floor(speed);
????????????????????if(div.offsetLeft==iTarget){
????????????????????????clearInterval(timer);
????????????????????}else{
????????????????????????div.style.left=div.offsetLeft+speed+'px';
????????????????????}
?????????????????????
????????????????},30);
????????????}?????
????????</script>


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

慕數(shù)據(jù)5775487 提問者

全局變量函數(shù)內部不可以用嗎?
2016-12-12 回復 有任何疑惑可以回復我~
#2

慕數(shù)據(jù)5775487 提問者

非常感謝!
2016-12-12 回復 有任何疑惑可以回復我~

?

? ? ? ? ? ? ? ? div.onmouseover=function(){

? ? ? ? ? ? ? ? ? ? move(this,0);

? ? ? ? ? ? ? ? }

function move(obj,iTarget){

? ? ? ? ? ? ? ? ? ? ?var div=document.getElementById('div');

? ? ? ? ?

? ? ? ? ? ? ? ? ? ? clearInterval(obj.timer);

? ? ? ? ? ? ? ? ? ? obj.timer=setInterval(function(){

? ? ? ? ? ? ? ? ? ? ? ? var speed = (iTarget-div.offsetLeft)/20;

? ? ? ? ? ? ? ? ? ? ? ? ? ? speed = speed>0?Math.ceil(speed):Math.floor(speed);

? ? ? ? ? ? ? ? ? ? ? ? if(div.offsetLeft==iTarget){

? ? ? ? ? ? ? ? ? ? ? ? ? ? clearInterval(timer);

? ? ? ? ? ? ? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? ? ? ? ? ? ? div.style.left=div.offsetLeft+speed+'px';

? ? ? ? ? ? ? ? ? ? ? ? }

? ? ? ? ? ? ? ? ? ? ? ? ?

? ? ? ? ? ? ? ? ? ? },30);

? ? ? ? ? ? ? ? }

? ? ? div變量放在里邊,math寫錯了 ? ? ? ? ??


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

舉報

0/150
提交
取消

錯在哪里?求大神幫忙!

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號