As you can see in http://jsfiddle.net/hn838/4/ 'click' is working fine for autofiller, But I want to trigger same code on enter key keypress also, but it is not working for me. My code is here for both. Click :
$('.ui-autocomplete').on('click', '.ui-menu-item', function(){
$('.college').trigger('click');
});
Keyprss :
$('.ui-autocomplete').on('keypress', '.ui-menu-item', function(e){
if (e.which == 13) {
e.preventDefault();
$('.college').trigger('click');
}
});
I want $('.college').trigger('click');
execution on click
and enter keypress
. click is working fine but keypress in not working.any clue ?
Rather than binding to key events, you could add a function to the select event:
select: function(){
$('.college').trigger('click');
}
That way it'd only trigger when the user actually selected the autocomplete value.
http://jsfiddle.net/louisbros/hn838/10/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With