+ 1

how can i fix my code?

i don´t know how to make the code diference between the different buttons ----------------------------------------------------------- <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <p style="text-align: center;"><strong>Puntaje HEMA</strong></p> <p>Izquierda:</p> <p id="i">0</p> <p>Derecha:</p> <p id="d">0</p> <p>Dobles:</p> <p id="t">0</p> <p>&nbsp;</p> <p style="text-align: center;">Puntos</p> <button onclick="add()">Izquierda</button> <button id="t" onclick="add()">Doble</button> <button id="d" onclick="add()">Derecha</button> <script> function add() { var score = document.getElementById("i").textContent score++ document.getElementById("i").innerHTML = score } </script> <script> function add() { var score = document.getElementById("d").textContent score++ document.getElementById("d").innerHTML = score } </script> <script> function add() { var score = document.getElementById("t").textContent score++ document.getElementById("t").innerHTML = score } </script> </body> </html>

12th Oct 2018, 2:13 AM
Rafael López del Puerto Tapia
Rafael López del Puerto Tapia - avatar
1 Resposta
12th Oct 2018, 3:16 AM
John Wells
John Wells - avatar