I am trying to use a if statement to determine which button/textbox is submitted.
For example In firefox/IE/Opera, the following code can always return true when I click the button labeled submitNameSearch as id;
$(document.activeElement)[0] === $("#submitNameSearch")[0]
However, when I test my code in chrome/safari, the return value is false.
May I ask if I did anything wrong?
Thanks a lot for your help!
If it’s triggered on a click, why don’t you just do:
and to see what element had focus before the focus was shifted to the clicked button you can always do :