亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

假如計時器改變樣式,但沒有延時效果

<script type="text/javascript">

? ?var str = document.getElementById("con");

? ? str.style.color="red";

? ? str.style.backgroundColor="#CCC";

? ? //str.style.display="none";

? ? setTimeout(str.style.color="green", 10000);

? </script>


正在回答

3 回答

1,為什么沒延時效果,因為setTimeout("計算表達式或函數",時間)

<script type="text/javascript">

//第一種方法

function oColor(){

str.style.color="green";

}

window.onload=function(){

str=document.getElementById("con")

str.style.color="red";

str.style.backgroundColor="#CCC";

setTimeout("oColor()",1000)

}

//第二種方法

// ?window.onload=function(){

// ?var str=document.getElementById("con");

// ?str.style.color="red";

// ?str.style.backgroundColor="#CCC";

// ?setTimeout("document.getElementById('con').style.color='green'", 1000);

// ?}

</script>

//可能是黏貼的問題,排版只能這樣了,希望你能看懂

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

<script type="text/javascript">

window.onload=function() {

var str = document.getElementById("con");

? ? ? ? ? ? ? str.style.color="red";

? ? ? ? ? ? ? str.style.backgroundColor="#CCC";

? ? ? ? ? ? ? ? // str.style.display="none";

}

? ? function change(){

? ? var str = document.getElementById("con");

? ? ? ? ?str.style.color="blue";

? ? ? ?}

? ? setTimeout("change()", 1000)

? ? </script>可以改成這樣,str.style.color="green"放進一個函數里

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

setTimeout("str.style.color='green'", 10000); ?這樣寫

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

舉報

0/150
提交
取消

假如計時器改變樣式,但沒有延時效果

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

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

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

公眾號

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