I’ve written a couple of posts recently about event delegation and guard clauses. There are many ways you can check the event.target when using event delegation: by its ID, by its classes, by its tag name, by its attributes, and more. But the easiest way is to use the matches() method.
When using event delegation, you need to make sure the element that fired the event is the one you wanted. This commonly involves wrapping your event handler within a conditional statement. Guard clauses are a way to make this process much cleaner.