I'm trying to change the img if the user clicks anywhere inside the specified div element. Nothing is happening, i know something must be wrong.
So far i have this
setInterval("myFunction()", 1);
function myFunction() {
if document.getElementById("demo").hasFocus; {
document.getElementById('pic1').src='https://pbs.twimg.com/profile_images/701853789855346689/iKxIyGkO.png';
} else {
document.getElementById('pic1').src='https://pbs.twimg.com/profile_images/688766010837446657/2DgfpAQ6.png';
}
}
<div style="border-style: solid;height:20px;" id="demo"></div>
<img id="pic1" src="https://pbs.twimg.com/profile_images/688766010837446657/2DgfpAQ6.png">