jQuery Q&A

Q:

I have always used the mouseover event, but while reading the jquery documentation I found mouseenter. They seem to function exactly the same. Is there a difference between the two, and if so when should I use them? (Also applies for mouseout vs mouseleave)

 

A:

You can try it out here on the jQuery doc page. It's a nice little, interactive demo that makes it very clear and you can actually see for yourself.

In short, you'll notice that a mouse over event occurs on an element when you are over it - coming from either its child OR parent element, but a mouse enter event only occurs when the mouse moves from the parent element to the element.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章