我想按自动向下箭头键时,用户按下我的CONTENTEDITABLE DIV进入,这里是我的代码试图如何在用户进入该div时按下按键事件?
$('body').on('keypress', '.chat_txt', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopPropagation();
$(this).append('\n');
$(this).trigger({ type: 'keypress', which: 40});
}
});
但不幸的是这个代码是徒劳的。
的jsfiddle https://jsfiddle.net/2q9x4xzm/
[模拟按键时使用jQuery(HTTP的://计算器。 com/questions/1468384/simulate-keypress-with-jquery) – Tibrogargan