Reputation: 68710
This looks really bloated, can it be rewritten any better/more compact:
$("#cart-summary").hover(
function () {
$('.flycart').slideDown('fast');
}
);
$(".flycart").hover(
function () {}, // mousein function not required
function () { // hide menu on mouseout
$('.flycart').slideUp('fast');
}
);
$('.flycart a.close').click(function(){
$(this).parents('.flycart').hide();
});
Thanks!
Upvotes: 0
Views: 2844
Reputation: 11977
$("#cart-summary").mouseenter(function () {
$('.flycart').slideDown('fast');
});
$(".flycart")
.mouseleave(function () {
$(this).slideUp('fast');
})
.find('a.close')
.click(function(){
$(this).parents('.flycart').hide();
});
It's a small improvement, though. I couldn't guess the relationship between the #cart-summary
and the .flycart
s.
Upvotes: 2
Reputation: 97631
In short, no. However, you can do without the empty hover function: just use
mouseenter()
and mouseleave()
. mouseover
and mouseout
have subtle differences to mouseenter
and mouseleave
. Look at the jQuery API for more info.
$("#cart-summary").mouseenter(function()
{
$('.flycart').slideDown('fast');
});
$(".flycart").mouseleave(function()
{
$(this).slideUp('fast');
});
$('.flycart a.close').click(function()
{
$(this).parents('.flycart').hide();
});
Upvotes: 1