I have a div element to which I am dynamically generating an input field and an image besides it. When I click on the input field and then use the tab key, the image gets the focus.
What I want to do
When the image has the focus, I want to trigger an enter key event.
HTML
<div id="myDiv"></div>
JQuery
$(document).ready(function(){
$("div#myDiv").html("<input type='text' tabindex='1'></input><a><img src='icon.gif' tabindex='2'></img></a>");
});
Just us the
focusevent on the image. I added afocustriggerclass to the image so that this code does not apply to allimgelements.