退格和删除按钮不会删除IE上的textarea中的字符

ron*_*nan 0 javascript jquery internet-explorer

在我的应用程序中,我有一个文本区域,用户无法删除使用退格键输入的字符或使用IE9中的删除键.这适用于Chrome.

我有以下代码

$('textarea').live('keydown', function(e) {
        var keyCode = e.keyCode || e.which;
        if (keyCode == 9) {
            var currentIndex = getCaret($(this).get(0))
            selectText($(this), currentIndex);
            return false;
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

我使用jQuery.highlighttextarea.js突出显示模式上的单词.我不确定是否 需要修改jQuery.highlighttextarea.js来处理退格或删除.请建议

我确实用过它

我确实用过它

if (e.which == 9) {
var currentIndex = getCaret($(this).get(0))
            selectText($(this), currentIndex);
            return false;
    }

if (e.which == 8 || e.which == 46)  {
    return false;

}
Run Code Online (Sandbox Code Playgroud)

但是现在退格或删除不起作用

Pri*_*ner 5

键码9是tab.点击此处:http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes

你想846,所以是这样的:

if (e.which == 8 || e.which == 46) return false;
Run Code Online (Sandbox Code Playgroud)