I'm trying to code a simple game in an HTML document just for fun.(我试图在HTML文档中编写一个简单的游戏只是为了好玩。)
In it, there is an image which adds to your score when clicked.(单击其中的图像会增加您的分数。)
I created a simple if
statement within the score-adding function which should change the image and what it's onClick
value is...(我在分数添加功能中创建了一个简单的if
语句,该语句应该更改图像及其onClick
值是...)
if (foo == 1) {
document.getElementById("test").src = "images/test2.png";
document.getElementById("test").onClick = "foo2()";
}
...but it doesn't work.(...但是它不起作用。) The image will be successfully changed, but the actual onClick remains the same.(图像将成功更改,但实际的onClick保持不变。) Checking the console, it throws no errors, either.(检查控制台,它也不会引发任何错误。)
ask by Poyo translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…