How can I increment a value inside HTML?

increment, javascript

Solution

`value` is not a valid attribute for the `<p>` tag.

I think you want something like:

function rps() {
    var computerScore = document.getElementById('computerScore');
    var number = computerScore.innerHTML;
    number++;
    computerScore.innerHTML = number;
}

...

<b>computer score:</b><p id="computerScore">0</p>

Problem

I'm completely new to JavaScript. I'm trying to increment a variable inside the HTML, it's not working. Is my syntax wrong? ``` <script> function rps() { computerScore.value++; computerScore.innerHTML = computerScore.value; } </script> <html> <b>computer score:</b><p id="computerScore" value="0">-</p> <button type="button" onclick="rps()">Go</button><br> </html> ```

Original source

Related problems