hover()
function requires two parameters: one for activation and one for deactivation. Here's an example:
$("a.moreDetails").hover(function() {
$(this).next("div.details").stop().show("fast");
}, function() {
$(this).next("div.details").stop().show("slow");
});
It's recommended to use stop()
in animations to prevent unintended visual artifacts caused by animation queuing.
Edit: Positioning the element next to the link can be tricky. You can modify the CSS:
div.details { display: inline; }
However, this may cause issues with jQuery effects, as they typically set elements to display: block
. If you don't need the effect, you can create a class:
div.details { display: inline; }
div.hidden { display: none; }
Then, update the jQuery code to add and remove the hidden class:
$("a.moreDetails").hover(function() {
$(this).next("div.details").addClass("hidden");
}, function() {
$(this).next("div.details").removeClass("hidden");
});