DEV Community

Discussion on: jQuery and Javascript - Business and User Interface Logic Terminology

Collapse
 
lexlohr profile image
Alex Lohr • Edited

You can avoid to use ready if you bind your handlers directly to document and use event.target to check if it suffices:

document.addEventListener('click', (ev) => {
  if (ev.target.nodeName === 'H1') {
    alert('This is a header.')
  }
})
Enter fullscreen mode Exit fullscreen mode

To do that, you even don't need jQuery.

Collapse
 
prem874 profile image
prem874

Yes

Collapse
 
saoud profile image
Saoud

Awesome thanks! I bet that is something that is an upcoming lesson as well. :)