When I click on a DIV I need to press the TAB key (in order to go from one input field to the next one).
I tried this code but is not working:
$("#change_logo").click(function() {
e = jQuery.Event("keydown");
e.which = 9;
// This is the ID of the input where I want to simulate the "Press TAB Key"
// and then I will go automatically to the following input which ID is
// #newsletter_section_title2
$("#newsletter_section_title1").trigger(e);
});
I know there are so many different ways to do this, .focus(), etc. How ever, for another reasons I need to do it simulating a TAB key pressed (but the user don’t press TAB, the user only click on a div).
Anyone knows how to do it?
Many thanks,
Dani
Simulating a tab press won’t do the job here, it’s not that you’re doing anything incorrect, it’s that simulating an event doesn’t often invoke the default action, in this case focusing the next field. For example
.click()on a<a>won’t follow the link either.You need to go the
.focus()route,$('#newsletter_section_title2').focus(), to get the effect you want here…what are your reasons for avoiding it to begin with?