سؤال

$('body').keyup(function(e)
{
    var code = e.keyCode ? e.keyCode : e.which;

    switch(code)
    {
        case 8:
        alert('blah');
        break;
    }
});

When a user hits backspace, I want the alert to pop up UNLESS the cursor is positioned within a textearea, input, etc.

Any ideas on how to do this?

هل كانت مفيدة؟

المحلول

Make sure that e.target.nodeName is not "INPUT" nor "TEXTAREA", etc.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top