Click event : Getting the id of the clicked element

I have a few images on screen and trying to catch a click event. I have read the various threads and have tried this code:

I get a blank reply for console.log(event.target.id) and don’t get the id of the element which has been clicked. What am I doing wrong?

try following:
$$('a').on('click',function(){ var thisId = $$(this).attr('id'); console.log(thisId); });

2 Likes

Great, that worked. :slightly_smiling_face:.
Any suggestions as how to detect a double click?

Dom7('myElement').on('dblclick', () => { console.log('dbclk') })
2 Likes

Thank you :slight_smile: