Let’s say i have a simple page that just contains a button that when clicked adds 1 to a java script num variable:
HTML:
<body>
<div>
<button type="button" onclick="someFunction()">Clicking here adds 1 to the "count" variable</button>
</div>
<br>
<div id="output"></div>
</body>
Javascript:
var count = new num;
someFunction() {
count =+ 1;
}
So my question is what would you put into the js to display the “count” varible in the div with the id “output”? do you use innerHTML? Because that doesn’t seem to work….
Also, is it possible with or without jQuery?
Why not? However, you have to note that number increment must be done with
count += 1or shortercount++. In the following example I have used prefix increment to do the calculation before assignment.Additionally, consider initialising numeric variables with its’ initial values as described above.