0

I've got a focusout event where if the relatedTarget of the event was a button with one id I was doing some actions. I've recently seen that relatedTarget's value in FF and safari is always null so my code is not crossbrower and not valid for my purpose. Is there any crossbrowser way to know what is the new focused element in a focusout event?

My old code:

$(document).on('focusout', 'myclass', function (e) {
    if ($(e.relatedTarget).attr('id') == 'mybutton') {
        prevElem = $(this);
    }
    else {
        prevElem = "";
        }
}

Thanks in advance

MKP
  • 117
  • 3
  • 14
  • Maybe document.activeElement will help you. Please, see http://stackoverflow.com/questions/11277989/how-to-get-the-focused-element-with-jquery it seems like you need – Sabik Sep 19 '16 at 14:58
  • 1
    That always returns the body object. Thanks! – MKP Sep 19 '16 at 15:06

0 Answers0