Michal
Michal

Reputation: 335

Interacting with icons through TABing

I have a jquery form window with mutliple objects that can be interacted with, buttons, text and finally the "X" icon.

    $('#cancel-feedback, #feedback-dialogs .icon-close, #feedbackCloseAfter').click(function (e) {
    closeDialog();
});

What I do not understand is why when I TAB through the objects to the "#cancel-feedback" (which is a button) and hit enter key the window closes but when I repeat the same process for the icon it does not.

Clicking with the mouse cursor works fine for both cases.

Upvotes: 1

Views: 43

Answers (1)

GH Karim
GH Karim

Reputation: 323

That's because the default behavior for a button is submit considered by some browsers specially IE. If you want to avoid this behavior make sure the button type is set explicitly:

For example

<button type="button">

Working example

Upvotes: 2

Related Questions