I have this javascript code
function change (elem){
if (x==1) elem.innerHTML = "1";
else elem.innerHTML = "not 1";
}
var test = document.getElementById ("abc");
var x=1;
test.addEventListener ("click", change(test));
and the html looks like this
<body>
<div id="abc">a div</div>
</body>
How do I prevent the function from being executed until the div element is clicked? Right now it just changes the innerHTML by itself and I want it to wait for the click listener.