Please help I have struggled on this with my cookie clicker-like game and I can't figure it out.
Sounds like 'event delegation' would be useful Assuming your image includes some distinguishing factor (className or id); Basically add an event listener to the whole container/window and observe if className matches with your image else do nothing
const imageClickObserver = (e) => {
if(e.target.className === 'image') {
cookiePoints++;
alert('clicked on image')
}else {
return;
}
}
window.addEventListener('click' imageClickObserver)
If I misunderstood your question and all you care of is to make your elements 'clickable'/'not clickable' then you can read this thread. Add CSS cursor property when using "pointer-events: none"