$('#pop_up').on('keyup','.textual',function(e){
var did= $(this).attr('data-id');
if(did == "titles_sendto" && e.which == 13){
$('#ListedAuthSend').append('<li>'+ this.value +'</li>');
this.value = '';
}
});
KeyCode === 13 having trouble with the dynamic element
-
30-05-2022 - |
سؤال
Here is a Bin = http://jsbin.com/ekasuv/1/edit
code I am using is this:
$('#pop_up').on('keyup','.textual',function(event){
var did= $(this).attr('data-id');
if(did ==="titles_sendto"){
var keycode = (event.keyCode ? event.keyCode : event.which);
if(keycode === '13') {
var AuthSendUser = $(this).val();
$('#ListedAuthSend').append('<li>'+ AuthSendUser +'</li>');
$(this).val(" ");
}
}
});
Though everytime I press enter it does not pass the code. Now maybe I am overlooking something or just forgetting something. though I am tired, and need some of S.O assistance. Can someone take a glance and see what I may be doing wrong.
I've also tried .on('focus',
المحلول
نصائح أخرى
If I understood you correctly, your code doesn't pass the if statement when you press enter? This works for me:
if(keycode == '13'){
alert('passed');
}
just use two =
sign and it works fine. Here's your edited JSBIN.
لا تنتمي إلى StackOverflow