The code above is wrong... here:

$().keydown(function(e) {
        var $item = $(".selected").removeClass("selected");
                if (e.keyCode === 40) { // bottom
                        if ($item.next().is("li")) {
                                $item.next().addClass("selected");
                                alert($item.get(0).innerHTML);
                        }
                }
        });
});


Also consider using a plug-in...
http://jquery.bassistance.de/autocomplete/demo/

Reply via email to