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

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

為什么沒效果呢

<!doctype?html>
<html>
<head>
<meta?charset="utf-8">
<title>無標(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>

為什么移入移出都沒效果呢?怎么也找不到問題在哪 也不報錯

正在回答

2 回答

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

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<title>無標(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(){ ?//定時器

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];你這句話錯了

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

舉報

0/150
提交
取消
JS動畫效果
  • 參與學(xué)習(xí)       113920    人
  • 解答問題       1487    個

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

進(jìn)入課程

為什么沒效果呢

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

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

幫助反饋 APP下載

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

公眾號

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