Difference between focus and focusin and also between blur and focusout

There are events – focusin and focusout – present in jQuery along with focus and blur.

Though, focusin seems to be behaving similar to focus and focusout similar to blur, but there does exist difference between them.

The major difference between focusin and focus, and on the same lines, between focusout and blur is that of event propagation.

If we use focusin & focusout then the event will bubble as against focus & blur where the event will not bubble.

Thus, focusin & focusout add the characteristic of event bubbling. Such a thing can be useful in case when one wants to relate the behavior of parent & child, that is, when we want that some action which takes place on one leads to an effect on other too. In all such cases, we can use focusin or focusout in place of focus and blur.

Javascript has the corresponding onfocusin and onfocusout events though there are cross browser compatibility issues associated with them and thus should be used with caution.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s