1

I want to display my chart when the mouse is hover some element. Everything works fine except I can't stop the slideToggle returns its original position.

Once the mouse is "out-of-target" it contracts, but if the mouse still at the chart it should stay appearing.

$(document).ready(function () { $("#test").hover(function () { $("#chart_div").slideToggle('slow'); }); }); 

I made a jsFiddle for this question instead of pasting here the whole bunch of code.

EDIT

Here is a goal example.

2 Answers 2

2

You can do it by defining both mouseenter and mouseleave events like this sample:

$(document).ready(function() { $("#test").mouseenter(function() { $("#chart_div").show('slow'); }); $(".outerClass").mouseleave(function() { if(!$('#chart_div').is(':hover')) { $("#chart_div").hide('slow'); } }); });​ 

Where your html structure should resemble this sample:

<div class="outerClass"> <div id="test"><strong>TEST.</strong></div> <div id="chart_div"></div> </div> <div id="another_div">here is out of the pie div</div> 

Live Example

Sign up to request clarification or add additional context in comments.

3 Comments

I don't get why is not hiding once the mouse left the chart. I tried your live example with firefox and IE 8+ and still the same. Is it working perfectly for you?
well, it will only disappear when mouse is out of 'outerClass'. It seems silly on this example but that might work on a well constructed-crowded html structure.
I will check your last one tomorrow, and accepted of course. Regards
1

The best solution would be to change this to a .click()

but if you need the chart to display when you move your mouseover TEST and hide when you move your mouse back over test then you .mouseenter()

$(document).ready(function() { $("#test").mouseenter(function() { $("#chart_div").slideToggle('slow'); }); });​ 

http://jsfiddle.net/fnTXQ/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.