I have a
$(document).keyup(function(e) {
//some code is here
});
code, that works as expected: it fires when I press any key on the keyboard. I want it to fire, but not when the cursor is in the
<input type="text" id="excludeMeFromFiring">
which is on the page.
How to modify the code above to exclude firing when typing in the input text field with a special id? So it doesn't fire if the cursor is in the input text field.
Thank you.
It's easy to do that in the
keyupfunction:That's the general case; because
inputelements can't have any elements within them, you could just usee.target.idrather thanclosest:I use
closestwhenever the element can have other elements inside it.