我想實(shí)現(xiàn)點(diǎn)擊一下字體變一種顏色,再點(diǎn)擊變回原來的顏色。請(qǐng)問哪里錯(cuò)了,謝謝。
<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("數(shù)組第一個(gè)值是:"+myarr[1]+"<br>");
? document.write("數(shù)組第二個(gè)值是:"+myarr[2]+"<br>");
? document.write("數(shù)組第三個(gè)值是:"+myarr[0]+"<br>");
</script>
</head>
<body>
? ? <input name="button" value="點(diǎn)擊變色" onclick="aa()"/>
</body>
</html>
2017-02-15
document.getELementById("input")
?<input name="button" value="點(diǎn)擊變色" onclick="aa()"/>根本沒有設(shè)置ID名
2017-02-15
親,先把id弄清楚吧
2017-02-15
<!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("數(shù)組第一個(gè)值是:"+myarr[1]+"<br>");
? document.write("數(shù)組第二個(gè)值是:"+myarr[2]+"<br>");
? document.write("數(shù)組第三個(gè)值是:"+myarr[0]+"<br>");
</script>
</head>
<body>
? ? <input type="button" value="點(diǎn)擊變色" onclick="aa()" id='ipt'/>
</body>
</html>
if判斷用“==”,用“=”是賦值了