tags:

views:

314

answers:

3

What is the difference between the onFocus and onMouseEnter event?

+8  A: 

onFocus, when applied to form elements, is triggered when the field is given focus by either tabbing to the field or clicking on it so you can enter a value. Most HTML elements are not given focus through onMouseEnter in any case, so the two events are completely different.

Salty
Also, only IE supports the mouseenter event natively. All browsers support the focus event.
Crescent Fresh
+1  A: 

You get the onMouseEnter when the mouse just hovers over the object. You can also get focus with the keyboard by tabbing to the control or programatically.

heavyd
+2  A: 

The onfocus event fires when the user clicks on an element, usually <input> or <textarea> elements, and the mousover event fires when the pointer mouses over any element on the page. The mouseenter event, however, is a non-standard event used by IE and implemented by some javascript libraries.

tj111
Actually `mouseenter` is native in IE.
Crescent Fresh
Thanks, updated the answer.
tj111