beat.src=="img/gray.png" 這一句過(guò)不去
<!doctype?html> <html> <head> <meta?charset="utf-8"> <title>星星之火可以燎原</title> </head> <body> <img?id="beat"?src="img/gray.png"?onclick="light()"?/> </body> <script> function?light(){ var?beat=document.getElementById("beat"); if(beat.src=="img/gray.png"){ beat.src="img/yellow.png"; }else{alert(44); beat.src="img/gray.png"; } } </script> </html>
2015-04-11
訪問(wèn)Element的屬性可以用 getAttribute方法,設(shè)置Element屬性可以用setAttribute方法,具體用法