Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery on hover not functioning

I'm changing my codes to be compatible with jQuery 1.8 and I'm stuck with this hover which doesn't work. When I used then same thing with a click it worked. Here is my code, can anyone tell me where I'm going wrong?

$(document).on('hover', '.top-level', function (event) {   $(this).find('.actionfcnt').show();   $(this).find('.dropfcnt').show(); }, function () {   $(this).find('.dropfcnt').hide('blind', function () {     $('.actionfcnt').hide();   }); }); 
like image 594
Param Veer Avatar asked Sep 04 '12 09:09

Param Veer


People also ask

How to use hover function in jQuery?

jQuery hover() MethodThe hover() method specifies two functions to run when the mouse pointer hovers over the selected elements. This method triggers both the mouseenter and mouseleave events. Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.

Is hover deprecated in jQuery?

hover() is deprecated #66.

How to call a function on mouseover in jQuery?

The mouseover() method triggers the mouseover event, or attaches a function to run when a mouseover event occurs. Note: Unlike the mouseenter event, the mouseover event triggers if a mouse pointer enters any child elements as well as the selected element.


1 Answers

Deprecated as of jQuery 1.8: The name "hover" used as a shorthand for the string "mouseenter mouseleave". It attaches a single event handler for those two events, and the handler must examine event.type to determine whether the event is mouseenter or mouseleave. Do not confuse the "hover" pseudo-event-name with the .hover() method, which accepts one or two functions.

Source: http://api.jquery.com/on/#additional-notes

That pretty much says it all, you cant use "hover" for that:

$(document).on('mouseenter','.top-level', function (event) {     $( this ).find('.actionfcnt').show();     $( this ).find('.dropfcnt').show(); }).on('mouseleave','.top-level',  function(){     $( this ).find('.dropfcnt').hide('blind', function(){         $('.actionfcnt').hide();     }); }); 
like image 196
nbrooks Avatar answered Oct 14 '22 09:10

nbrooks