I have defined a function like so:
var hovername = function() {
// do something
}, function() {
// do something
});
But when I call it using somevariable.hover(hovername);, it displays an error: Missing variable name }, function() {.
I removed the second function and it works okay but the mouseout part of the hover event is gone.
How do I define a function then for a hover event which accommodates for the mouseout event? Or do I use mouseout and mouseover events instead of just hover?
http://api.jquery.com/hover/
jQuery hover accepts 2 parameters as functions.
You can either do it such is
or with annoymous functions
Your problem lies within the 2nd declaration of a missing variable name and you’re only passing in one of the parameters.
var hovername = function() {
// do something
}, function() { // missing a variable name here
// do something
});