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

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

我想實現點擊一下字體變一種顏色,再點擊變回原來的顏色。請問哪里錯了,謝謝。

<script language="javascript">

?/*var myarr = new Array(3);

?myarr[0]=88;

?myarr[1]=90;

?myarr[2]=68;*/

?

?myarr = [88,90,68];

?

? ? function aa(){

? ? ? ?if( document.getELementById("input").style.backgroundColor="red"){

? ? ? ? ? ?document.getELementById("input").style.backgroundColor="blue"

? ? ? ?}

? ? ? ?else{

? ? ? ? ? ?document.getELementById("input").style.backgroundColor="red"

? ? ? ?}

? ? }


? document.write("數組第一個值是:"+myarr[1]+"<br>");

? document.write("數組第二個值是:"+myarr[2]+"<br>");

? document.write("數組第三個值是:"+myarr[0]+"<br>");

</script>

</head>

<body>

? ? <input name="button" value="點擊變色" onclick="aa()"/>

</body>

</html>


正在回答

3 回答

document.getELementById("input")

?<input name="button" value="點擊變色" onclick="aa()"/>根本沒有設置ID名

1 回復 有任何疑惑可以回復我~
#1

qq_哦哦_10 提問者

非常感謝!
2017-02-15 回復 有任何疑惑可以回復我~

親,先把id弄清楚吧

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

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title> 卸載事件 </title>

<script language="javascript">

?/*var myarr = new Array(3);

?myarr[0]=88;

?myarr[1]=90;

?myarr[2]=68;*/

?

?myarr = [88,90,68];

?

? ? function aa(){

? ? ? ?if( document.getElementById("ipt").style.backgroundColor=="red"){

? ? ? ? ? ?document.getElementById("ipt").style.backgroundColor="blue"

? ? ? ?}

? ? ? ?else{

? ? ? ? ? ?document.getElementById("ipt").style.backgroundColor="red"

? ? ? ?}

? ? }


? document.write("數組第一個值是:"+myarr[1]+"<br>");

? document.write("數組第二個值是:"+myarr[2]+"<br>");

? document.write("數組第三個值是:"+myarr[0]+"<br>");

</script>

</head>

<body>

? ? <input type="button" value="點擊變色" onclick="aa()" id='ipt'/>

</body>

</html>

if判斷用“==”,用“=”是賦值了

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

風之思語

getElementById l是小寫
2017-02-15 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

我想實現點擊一下字體變一種顏色,再點擊變回原來的顏色。請問哪里錯了,謝謝。

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

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

幫助反饋 APP下載

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

公眾號

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