0

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 :)

1
  • Hello and welcome to SO! Take a look at how I edited your post to make it more readable. That'll help you get a quicker and better answer to your question here at SO. (Code should be formatted as code. You don't need HTML breaks to format the text. etc.) Hope that helps! Commented Feb 17, 2011 at 19:33

3 Answers 3

3

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);     
         });
}); 
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

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

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.