+ 1

Event execution in JS. With if statement.

I want to use if when button on webpage is clicked like If(//when button is clicked){//execute this}; And how could I display a claculated number like num = x+i = 10; in document.getelementbyid("id").innerHTML =num; Please write basic beginner codes. I need it fast. I need to make a code which calculates score when correct button is clicked.⌨

3rd Jan 2019, 6:04 PM
Sarthak Gupta
Sarthak Gupta - avatar
1 Resposta
+ 1
You can either do it in the html: <button id="enter" onclick="func()"></button> Or in javascript: document.getElementById("enter").onclick = function() { // Your Code }
3rd Jan 2019, 6:44 PM
Lemuel
Lemuel - avatar