I want to automatically press the down arrow when a user clicks on my content div, and here is my code that I tried
$('body').on('keypress', '.chat_txt', function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopPropagation();
$(this).append('\n');
$(this).trigger({ type: 'keypress', which: 40});
}
});
But, unfortunately, this code is barren.
JsFiddle
https://jsfiddle.net/2q9x4xzm/
source
share