Jump to content

Recommended Posts

Hi,

 

Please consider the following image:

 

post-91219-0-48083900-1354421353_thumb.png

 

As you can see, there are 4 divs being one big green, "test_div" and 3 small squre divs, "div_1"," div_2", "div_3".

 

All I want to do is trying to trigger some mouse events with these.

 

When the page is loaded, the following function is called and the above divs are basically all hidden:

 

function hide_div()

{

document.getElementById("test_div").style.visibility = "hidden";

}

 

and whenever the mouse cursor is over them another event is triggered with this function:

 

function show_div()

{

document.getElementById("test_div")style.visibility = "visible";

}

 

And html code(partial):

 

 

<div id="test_div" onmouseover="show_div();" onmouseout="hide_div();">

 

<div id="div_1"></div>

 

<div id="div_2"></div>

 

<div id="div_3"></div>

 

</div>

 

All it does is simply hide-and-show function, but when I actully do that it does't work what I intended;

 

when I put the cursor on "test_div"(green part only) it does show all the 4 divs correctly but as soon as I move the cursor

 

to the one of three square divs(div_1, div_2 or div_3; didn't really matter) all the divs are gone and sometimes it blinks.

 

I figured out that this is because onmouseover="show_div() is only triggered to "test_div" but apart from that I have no idea

 

how to solve this. Pleae help!! thanks.

Edited by programming.name
Link to comment
https://forums.phpfreaks.com/topic/271470-onmouseout-issue/
Share on other sites

Pretty sure onmouseover/onmouseout don't count for child elements.

 

Use CSS for this instead of Javascript.

#test_div > div { visibility: hidden; }
#test_div:hover > div { visibility: visible; }

Edited by requinix
Link to comment
https://forums.phpfreaks.com/topic/271470-onmouseout-issue/#findComment-1396819
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.