javascript - jQuery Keypress Arrow Keys steering in DropDown -
i have problem dropdown, connected database , can't control arrows , down move result mouse click. see code started writing doesn't work. doing wrong?
$(field-customer-dropdown).on("keydown", function(event) { var keycode = event.which; if (keycode == 38 || keycode == 40) { showdropdown(); } });
edit:
as made little code looks this:
$("body").on("keydown", function(event) { var keycode = event.which; if (keycode == 40) { console.log("key"); $(".drop-down-row:firstchild").css("backgroundcolor","red"); } });
and result: enter image description here how should code push keydown 40 switch data 1 on data 2?
can me?
javascript variables cannot contain -
in them. also, selector using not html tag, doesn't have prefix. if it's class
, prefix .
else if id
, prefix #
.
$(".field-customer-dropdown").on("keydown", function(event) { var keycode = event.which; if (keycode == 38 || keycode == 40) { showdropdown(); } });
Comments
Post a Comment