开发者

conditional check for focus is in textarea or input field

开发者 https://www.devze.com 2023-01-17 19:38 出处:网络
$(\'body\').keyup(function(e) { var code = e.keyCode ? e.keyCode : e.which; switch(code) { case 8: alert(\'blah\');
$('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 po开发者_JAVA百科sitioned within a textearea, input, etc.

Any ideas on how to do this?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消