0

I'm learning HTML 5 and I was trying to make my own Craps game.

Now the idea is that when the "Reset" button is pressed, all values will go back to the default and the canvas will be cleared. However when I do it, the image of the dice are still in the canvas.

Now I don't think there's anything worng with this:

ctx.fillStyle = "red";
ctx.fillRect(0,0,900,900);

but it doesn't work when it's in the reset method. When I put it in other method it works.

Here is the site and code is in it if anyone wants to see:

https://dl.dropboxusercontent.com/u/90543216/index.html

4

1 回答 1

1

您不能在表单环境中调用函数reset()reset()submit()是模拟<input type="reset">/的两个特殊函数<input type="submit">

如果您重命名resetresetGame,一切都会按预期进行。但是,您应该摆脱<form>并使用<button>而不是<input type="button">无论如何。

于 2013-10-26T13:23:22.937 回答