Brad Walls Brad Walls - 5 months ago 12
jQuery Question

on tab hit show/hide

I have a script that shows a div onclick, however I want the same logic to occur when the user hits the tab button.

$(document).ready(function(){
$("#password").click(function(){
$("#password-confirm").slideDown(600);
});
});


Can this function be used for a tab button? If so, how?

Answer

If you want to detect tab key from password field. You can try this:

$("#password").keydown(function (e) { 
  var keyCode = e.keyCode || e.which; 

  if (keyCode == 9) { 
    $("#password").trigger("click"); // trigger click event 
  } 
});
Comments