0

I have a form with on blur listener, when I click outside the form and the blur triggered, can I get the element that was clicked on?

ilyo
  • 35,851
  • 46
  • 106
  • 159

1 Answers1

0

You can always get the element that triggered any event with event.target, but you need to set up an event handler for that event. As @adeneo said, you'd need to set up a click event handler that would fire no matter where you might click. You could do this by setting the handler on document.click. However, this will fire even if you have clicked inside your form. You'd need to do some validation on the clicked element to be sure it's one that you are interested in.

Scott Marcus
  • 64,069
  • 6
  • 49
  • 71