Simple OnMouseOver Visibility:Visible Doesn't Work

Discussion in 'JavaScript' started by ColorWP.com, Sep 3, 2011.

Thread Status:
Not open for further replies.
  1. #1
    Hello.

    I have a simple DIV tag with the following code:
    <div id="fp323" onmouseover="setVisibility('fp323', 'inline');" 
    style="visibility:hidden;margin:0;padding:0;">
    Some Text Here</div>
    HTML:
    I also have this JS function before the above tag:
    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.getElementById(id).style.display = visibility;
    }
    </script>
    Code (markup):
    However, when I hover the Div, nothing happens, meaning the text doesn't show.
     
    Solved! View solution.
    ColorWP.com, Sep 3, 2011 IP
  2. #2
    It won't trigger onMouseOver/Out events if the element is not visible. You could wrap it with other div and add events to that div, so it modifies it's child properties.
     
    babushkyn, Sep 3, 2011 IP
  3. ColorWP.com

    ColorWP.com Notable Member

    Messages:
    3,121
    Likes Received:
    100
    Best Answers:
    1
    Trophy Points:
    270
    #3
    This worked. Thanks!

    <div OnMouseOver="setvisibility('unique_id','inline');" OnMouseOut="setvisibility('unique_id','none');">
      <div id="unique_id" style="display:none">Some text here that will be displayed on mouse hover and hidden when mouse is removed from it.</div>
    </div>
    HTML:


    <script language="JavaScript">
    function setVisibility(id, visibility) {
    document.getElementById(id).style.display = visibility;
    }
    </script>
    Code (markup):
     
    Last edited: Sep 3, 2011
    ColorWP.com, Sep 3, 2011 IP
Thread Status:
Not open for further replies.