I want an "if" that its condition is based on the location of the user click, but I have no idea how to refer to it. I believe that with this basis understand what I want to happen:
if (onclick == window) {executar bloco de código}
If you'd like to see my code:
HTML5: (revealing code only)
<li><img src="Backgrounds/Foto7.jpg" onclick="myFunction(this.src)"></li>...<div id="open">/*Imagem criada aqui*/</div></body>
Javascript: (I'm learning to report errors please)
function myFunction(a) {
var NewImg = document.createElement('IMG');
document.getElementById('open').appendChild(NewImg);
NewImg.className = "open";
NewImg.setAttribute('src',a);
var DELIMG = document.getElementById('open');
if (onclick == NewImg){DELIMG.removeChild(NewImg)}
}
For any additional information ask in the comments, sorry if there is a similar question (I could not find it).