How can I check whether my_func
was called from blur
or focus
, in the following code?
function my_func(my_arg) {
// Maintain compatibility with ECMAScript < 6
// https://stackoverflow.com/a/894877/1563422
my_arg = typeof my_arg !== 'undefined' ? my_arg : false;
if(my_arg) {
// do something
}
}
// Apply to both blur and focus, in case a user clicks from a field
// onto the background of the page, without focusing another field first
$('#appform').on({
'blur' : my_func,
'focus': my_func
}, 'input, select');