JQuery: When not hovering over element X or Y, hide Y?

Part of the problem can be the fact that you are loading the information with ajax.

Part of the problem can be the fact that you are loading the information with ajax. You need to use the live() function on data added to the page after the normal page load for scripts to work on the said data. Sort of like this: $('.

Day'). Live('mouseover mouseout',function(e) { if (e. Type === 'mouseover') { $(this).

AddClass('day-hover'); } else { $(this). RemoveClass('day-hover'); } }).

Yeah, this did it. After some playing around with it I got it to work. Thanks.

– qwerty Jul 29 at 13:01 Cool, happy to help :) – Mattis Jul 30 at 6:45.

The flashing will be because when you move the mouse over the tooltip, you're no longer hovering over that image and it's removing it, then when it's removed, you are all of a sudden hovering over the image again so it re-appears. Sounds like the onmouseout call of the image is being called before the onmouseover of the tooltip when you hover over the tooltip, so your currently_hovering variable is not set to the tooltip. Could you try using a timeout when you hover out of the image?

Even a timeout of 0 seconds might work, just enough to let the browser process that the tooltip has been hovered over before it checks the value of currently_hovering?

I'll try using a timeout, but I doubt it will work for one reason. Even if I remove the hiding function that hides the tooltip when I hover out of the image, it doesn't recognize when I hover over the tooltip. I can hover over the tooltip (and it's childrens) as much as I want to, but it still doesn't show up in the log.

I'll try it though, and get back as soon as i'm done. (I have to go away for about an our now so it might take some time, just so you know) – qwerty Jul 29 at 10:24 Aha, sounds like Mattis has cracked this one then. If you're dynamically creating the tooltip div, it won't have it's event handlers if you're using bind(), however if you use live(), when the object is created it will automatically bind the events.

– Connell Watkins Jul 29 at 10:28 Alternatively, you could create a hidden tooltip element with a unique id on page load, then bind the events, then use your AJAX call function to change the innerHTML, positioning and show the tooltip. – Connell Watkins Jul 29 at 10:30 Yeah that would be one solution Connel but I don't want to have to add a html element for every page I want this to work on. I just want to include a javascript file and have it working.

– qwerty Jul 29 at 12:47 Could you have your included javascript file add the div when the page has loaded? $(function() { createDiv(); }); – Connell Watkins Jul 29 at 12:50.

Maybe you can wrap your image into for example tag, have jquery "listen" on hover of that div tag and add your tooltip inside this tag right after image itself. Then hovering over tooltip shouldn't cause flickering, because you "dont leave" div that is causing it to be visible. Something like tooltip text then js would be something like $('div.

ImageWrapper'). Hover(function(){ var tooltipText = callWhateverMethodToLoadTooltipText(); if($('span. Tooltip',$(this)).

Length == 0) $(this). Append('' + tooltipText + ''); else $('span. Tooltip',$(this)).

Text(tooltipText).show(); }, function(){ $('span. Tooltip', $(this)).hide(); }).

Yeah but the problem is that the tooltip is loaded dynamically everytime I hover over an element with a certain class. Therefore I position it right before I close the body tag. – qwerty Jul 29 at 10:15 hmmmm, and do you have to add it right before end of body tag?

I'll try to describe what I mean in answer – petho Jul 29 at 10:17 Are you using the same tooltip element for every tooltip and changing the positioning? If not, you already have the image as a jQuery object, you could use .parent() to get the wrapper, then add the div as a child? – Connell Watkins Jul 29 at 10:24 hmmmm but still you would need a wrapper that is wrapping only that one image I guess, or maybe you mean completely different solution?

– petho Jul 29 at 10:30.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions