Shah
Shah

Reputation: 1654

How to button click event on jQuery focus

I have two text boxes and a button. I change the focus from one control to another whenever a keypress event is generated.

I want as soon the button get's focus it should call the click event i.e., *onclick="btnIssue_Click1".*

How this should be done in jQuery?

Upvotes: 0

Views: 534

Answers (1)

Rory McCrossan
Rory McCrossan

Reputation: 337713

$("#myButton").focus(function() {
    $(this).click();
});

It's worth noting that this is rather unusual behaviour, and is likely to confuse users.

Upvotes: 2

Related Questions