Hi,
I’ve tried numerous scripts to try to get a click within the browser to increment a number. But yet unsuccessful so far.
Clicking buttons to increment a number etc… Works fine. But for some reason the global event listener is a harder nut to crack for me.
I tried a couple of things and this and showing here. Maybe somebody can point me out where I got wrong and where I should look at.
And I have pen where you see that clicking below doesn’t change the incrementation:
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="main.css">
</head>
<body id="clickme" background="img.jpeg">
0
<script src="" async defer>
var button = document.getElementById("clickme"),
count = 0;
button.onclick = function() {
count += 1;
button.innerHTML = count;
};
</script>
</body>
</html>