最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么不能寫成obj.currentStyle[attr] || getComputedStyle(obj, false)[attr];

為什么不能寫成obj.currentStyle[attr] || getComputedStyle(obj, false)[attr];

慕田峪8701529 2017-08-23 22:25:00
window.onload=function(){ ? ?var aDiv=document.getElementsByTagName('div');? ? ? aDiv[2].onclick=function(){ ? ? ? ?startMove(this,"opacity",100) ? ?}}function startMove(obj, attr, iTarget){ ? ?clearInterval(obj.timer); ? ?obj.timer=setInterval(function (){ ? ? ? var iCur=0; ? ? ? ?var t=obj.currentStyle[attr]||getComputedStyle(obj, false)[attr]; ? ? ? ?if(attr=="opacity"){ ? ? ? ? ? ?iCur=parseInt(parseFloat(t)*100) ? ? ? ?} ? ? ? ?else{ ? ? ? ? ? ?iCur=parseInt(t); ? ? ? ?} ? ? ? ?var iSpeed=(iTarget-iCur)/8; ? ? ? ?iSpeed=iSpeed>0?Math.ceil(iSpeed):Math.floor(iSpeed); ? ? ? ?if(iCur==iTarget) ? ? ? ?{ ? ? ? ? ? ?clearInterval(obj.timer); ? ? ? ?} ? ? ? ?else ? ? ? ?{ ? ? ? ? ? ?if(attr=="opacity"){ ? ? ? ? ? ? ? ?obj.style.filter="alpha(opacity:"+(iCur+iSpeed)+")"; ? ? ? ? ? ? ? ?obj.style[attr]=(iCur+iSpeed)/100; ? ? ? ? ? ?} ? ? ? ? ? ?else{ ? ? ? ? ? ? ? ?obj.style[attr]=iCur+iSpeed+'px'; ? ? ? ? ? ?} ? ? ? ?} ? ?}, 30)}
查看完整描述

1 回答

?
橋本奈奈未

TA貢獻(xiàn)436條經(jīng)驗(yàn) 獲得超108個(gè)贊

currentStyle[attr] 獲取屬性值的寫法應(yīng)該沒問題,但是currentStyle是非標(biāo)準(zhǔn)的,是IE瀏覽器的API,其實(shí)現(xiàn)代瀏覽器已經(jīng)可以不用考慮這種情況了,

標(biāo)準(zhǔn)方法是通過getComputedStyle獲取CSSStyleDeclaration 對(duì)象,

然后通過CSSStyleDeclaration.getPropertyValue(attr)方法獲取屬性值

查看完整回答
反對(duì) 回復(fù) 2017-08-24
  • 1 回答
  • 0 關(guān)注
  • 1734 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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