I am trying to make a press enter to send data using jquery but my code is not working. Anyone can tell me what i am missing here ?
<textarea name="reply" class="reply" id="replyChat" placeholder="Write your message"></textarea>
JS
function SendMessage() {
$.ajax({
type: "POST",
url: "/ajax/reply",
data: dataString,
cache: false,
success: function(html) {
$('.messages-body').append(html);
}
});
}
$('#replyChat').bind('keydown', function(e) {
if(e.keyCode==13) {
SendMessage();
}
});
$('body').on("click",".reply-btn",function() {
SendMessage();
});
Click function is working fine just keydown doesn't work here.