jQuery bug or just strange behavior ?

Today I discovered some strange behavior of jQuery library, when I added some new functionality to our old adminstration.
So I’ve got Form element with some inputs and submit button. On inputs are binded click event. That mean that only if you click on input element Event will fire, right ? But I found that even if you press return key, Event fires too. I know that if you press return key and you are inside form element, Form will fire submit Event. But it fires click Event which is strange. jQuery documentation says:
//
The click event fires when the pointing device button is clicked over an element. A click is defined as a mousedown and mouseup over the same screen location. The sequence of these events is:

* mousedown
* mouseup
* click
//
Do you see any keyPress event or something, I don’t. I just don’t know if it is a bug or if it’s purpose. I also test if it’s because that keyPress Event or because that submit. It seems to me that if you press return key jQuery call submit Event and somehow call click Event too. Here is a example. What do you think ?

Solution for prevent this behavior is bind click Event only to inputs whith type text.

Btw: It works same way at all browsers.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.