i'm using smarty street auto-complete control. trying attach keydown event facilitate selection using "enter".
$('body').on('keydown', '.smarty-active-suggestion', function(event) { event.stopimmediatepropagation(); alert($(this).text()); });
not sure why not working. code @ http://plnkr.co/edit/1odvq81s4bbe9ro2usv4?p=preview
any appreciated.
thanks
the main thing had change work put code inside of $(document).ready(function() {
think make sure body loaded before attach listener it.
also, able react when enter button pressed , alert selected address code
$('body').on('keydown', function(event) { if (event.keycode === 13) { event.stopimmediatepropagation(); alert($(".smarty-active-suggestion").text()); } });
this check key pressed enter checking it's keycode.