First timer and javascript newbie here. I'm learning javascript a bit late, and I've run into a problem.
I have a counter that goes up by one when a user clicks a button. The code is here:
<script language="javascript">
var cnt = 0;
function cntClicks(){
cnt = cnt + 1;
document.getElementById('test').innerHTML = cnt;
}
</script>
<h1 id="test">0</h1>
<button onclick="cntClicks();">add 1</button>
So far it works, but I want an alert to pop up when someone clicks 100 times. I have no idea how to execute this, and also I would sincerely appreciate the answer included in HTML. This is because Wapka doesn't allow purely javascript files. Was I correct to think this would include an if statement focused on the innerHTML being > 99?
Aucun commentaire:
Enregistrer un commentaire