Clicky

Hi,

I would like to say on .hover() or on .click() in my function but I'm not sure how to code that.  Do I use the .on() function some how?  Any ideas?

This is my function:

     // hover captions over section.materials figure images     $("section.materials figure").hover(function () {         $("strong.caption", this).animate({ top: '104px' }, 500);         $(this).mouseleave(function () {             $("strong.caption", this).animate({ top: '143px' }, 400);         });     });                             
1: 2: 3: 4: 5: 6: 7: 

Select allOpen in new window

asked 11/26/2011 01:50

FairyBusiness's gravatar image

FairyBusiness ♦♦


4 Answers:
Whats the difference between mouseover and hover?  They seem to have the same affect to me. .
link

answered 2011-11-26 at 11:36:36

FairyBusiness's gravatar image

FairyBusiness

Greetings FairyBusiness,

The only difference between those two is that .hover() allows you to define the behavior on mouseenter and mouseleave of the element through two handlers as parameters, while mouseenter allows you one handler to that specific action.

Quoting jquery docs:

Calling $(selector).hover(handlerIn, handlerOut) is shorthand for:

1:
$(selector).mouseenter(handlerIn).mouseleave(handlerOut);


Also, if you have doubts on what's the difference between mouseover and mouseenter, read the Doc in Jquery (http://api.jquery.com/mouseover/). I always use mousenter.

Best regards,
-JJ
link

answered 2011-11-26 at 14:32:35

jjperezaguinaga's gravatar image

jjperezaguinaga

thanks
link

answered 2011-11-27 at 14:14:56

FairyBusiness's gravatar image

FairyBusiness

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×63

Asked: 11/26/2011 01:50

Seen: 296 times

Last updated: 12/12/2011 02:50

Categories