beat.src=="img/gray.png" 这一句过不去
<!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>