I have a jquery script that displays a div when any key on the keyboard is pressed. I’d like to add a condition to the script that will only run the script if no other input area (textarea or texfields) are in focus on the page. That way you can actually type on the rest of the page without showing the div.
$(document).on('keydown', function (e) {
if (!$('#test').is(':visible')) {
//######## IF (every input is not active....) {
if (65 <= e.keyCode && e.keyCode <= 90) {
$(elem).fadeIn();
$('#textarea').val('');
$('#textarea').focus();
$('#textarea').val(temp);
}
}
});
Thanks. I can give every other textarea on the page the same ID if that is necessary.
Use jQuery’s focus pseudoselector
Or for your code example