Reputation: 395
I'm having an issue with a basic Javascript program. When this script is run as-is, the button disappears. I'm trying make it so it continues to print the life total while either respawning the button or keeping it in place. Is there an easy way to do this? I have a snippet included below to demonstrate what I'm trying to do.
<html>
<input type="button" value = "+" onclick="addLife()">
<script>
var player1life = 20;
function addLife()
{
player1life++;
document.write(player1life);
document.write("<br>");
}
</script>
</html>
Upvotes: 2
Views: 320