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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -