Dwayne
Dwayne

Reputation: 141

jQuery Hover Problems

I've got this problem with some jQuery. I want to display this div when you hover over an element and hide it when you aren't on it.

$(function() {
    $('#projects').hover(function() {
        $('#projects .pane').show(200), $('#projects .pane').hide(200);
    })
});

When you hover it disappears the same time.

Thanks :)

Upvotes: 0

Views: 100

Answers (3)

Eray
Eray

Reputation: 7128

$(function() {
    $('#projects').hover(function() {
        $('#projects .pane').show(200)},

            function() {$('#projects .pane').hide(200);}
    )
});

http://jsfiddle.net/fCbQv/1/

Upvotes: 1

Chandu
Chandu

Reputation: 82893

You forgot the function(){ seperator, hence the current code is including hide and show in the mouse over event. Try this:

$(function() {     
    $('#projects').hover(function(){         
        $('#projects .pane').show(200)
        }, function(){
         $('#projects .pane').hide(200);     
         });
}); 

Upvotes: 3

Sarfraz
Sarfraz

Reputation: 382656

Your code should look like this:

$(function() {
    $('#projects').hover(function() {
        $('#projects .pane').show(200);
    }, function(){
        $('#projects .pane').hide(200);
   });
});

The hover expects two function parameters. One for when mouse is over and other one when mouse is away.

Upvotes: 1

Related Questions