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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

錯(cuò)在哪里?求大神幫忙!

<!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 回復(fù) 有任何疑惑可以回復(fù)我~
#1

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

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

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

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

?

? ? ? ? ? ? ? ? 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寫錯(cuò)了 ? ? ? ? ??


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
JS動(dòng)畫效果
  • 參與學(xué)習(xí)       113917    人
  • 解答問題       1502    個(gè)

通過本課程JS動(dòng)畫的學(xué)習(xí),從簡單動(dòng)畫開始,逐步深入各種動(dòng)畫框架封裝

進(jìn)入課程

錯(cuò)在哪里?求大神幫忙!

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)