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

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

為什么沒(méi)效果呢

<!doctype?html>
<html>
<head>
<meta?charset="utf-8">
<title>無(wú)標(biāo)題文檔</title>
<style?type="text/css">
body?{margin:0;}
.divs?{
	width:200px;
	height:200px;
	background:?red;
	opacity:0.3;
	filter:alpha(opacity:30);
	cursor:pointer;
	}
</style>
<script?type="text/javascript">

window.onload?=?function(){
	var?timer?=?null;
	var?apa?=?30;
	var?oDiv=document.getElementsByClassName("divs")[0];
	function?Alphas?(iTarget){
	
		clearInterval(timer);
		var?Speed?=?0;
			if(iTarget>apa){
				Speed?=?10;
			}else?if(iTarget<apa){
				Speed?=?-10;	
			}
		
		timer?=?setInterval(function(){
			if(apa?==iTarget){
				clearInterval(timer)	
			}else{
				apa+=Speed;
				oDiv.style.opacity?=?apa/100;
				oDiv.style.filter="alpha(opacity:"+apa+")";
				//console.log(apa);
			}
		},20)
	oDiv.onmouseover=function(){
		Alphas(100);		
	}
	oDiv.onmouseout=function(){
		Alphas(30);	
	}	
	}
}

</script>
</head>

<body>
<div?class="divs"></div>
</body>
</html>

為什么移入移出都沒(méi)效果呢?怎么也找不到問(wèn)題在哪 也不報(bào)錯(cuò)

正在回答

2 回答

挺多錯(cuò)誤的, 最致命的錯(cuò)誤是把所有的定義函數(shù)放在widow.onload下了,其次定時(shí)器也錯(cuò)了?

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>無(wú)標(biāo)題文檔</title>

<style type="text/css">

body {margin:0;}

#divs {

? ? width:200px;

? ? height:200px;

? ? background:red;

? ? opacity:0.3;

? ? filter:alpha(opacity:30);

? ? cursor:pointer;

? ? }

</style>

<script type="text/javascript">


window.onload = function(){

? ? var oDiv=document.getElementById('divs');

oDiv.onmouseover=function(){

? ? ? ? Alphas(100); ? ? ??

? ? }

? ? oDiv.onmouseout=function(){

? ? ? ? Alphas(30);

? ? } ?

}



? ?var timer = null;

? ? var apa = 30;

? ? function Alphas (iTarget){

? ? ? ?clearInterval(timer);

var oDiv=document.getElementById('divs');

? ? ? ? timer= setInterval(function(){ ?//定時(shí)器

var Speed = 0;

? ? ? ? ? ? if(iTarget>apa){

? ? ? ? ? ? ? ? Speed = 10;

? ? ? ? ? ? }else if(iTarget<apa){

? ? ? ? ? ? ? ? Speed = -10;?

? ? ? ? ? ? }

? ? ? ? ? ? if(apa ==iTarget){

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

? ? ? ? ? ? }else{

? ? ? ? ? ? ? ? apa+=Speed;

? ? ? ? ? ? ? ? oDiv.style.opacity = apa/100;

? ? ? ? ? ? ? ? oDiv.style.filter="alpha(opacity:"+apa+")";

? ? ? ? ? ? ? ? //console.log(apa);

? ? ? ? ? ? }

? ? ? ? },20)

? ?

? ? }


?

</script>

</head>

?

<body>

<div id="divs"></div>

</body>

</html>


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

var?oDiv=document.getElementsByClassName("divs")[0];你這句話錯(cuò)了

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

舉報(bào)

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

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

進(jìn)入課程

為什么沒(méi)效果呢

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

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

幫助反饋 APP下載

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

公眾號(hào)

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