I want to check if one of this element is clicked:
<li id="myProjets" onclick="dropdown(this)">
<img src="img/image.png">
<span>Projets</span>
</li>
This is my code:
window.onclick = function (event) {
if (event.target.matches('#myProjets')) {
console.log('element clicked');
}
}
When I click in the image or the span it doesn't work