HTML div related problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • varindergupta
    New Member
    • Nov 2008
    • 1

    HTML div related problem

    hi guys, i want to call a fucntion on the onmouseout event whenever i get out of the outer div, but even when i try to move my mouse from one inner div to another the fuction gets called. i want the function should only get called when i move my mouse out side the outerdiv,,, please solve my problem..ASAP

    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    <script>
    var funval;
    function setfun()
    {
    	funval=2;
    }
    function getfun()
    {
    	alert(funval);
    }
    </script>
    </head>
    
    <body>
    <table>
    <tr>
    <td>
    
    <div style="bgcolor=red;cursor:hand" onmouseout="getfun();">
    <table>
    <tr>
    <td>
    <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Sunset.jpg"  ></div>
    </td>
    </tr>
    <tr>
    <td>
    <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Water%20lilies.jpg" onmouseover="setfun();"></div>
    </td>
    </tr>
    <tr>
    <td>
    <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Winter.jpg"></div>
    </td>
    </tr>
    </table>
    
    </div>
    </td>
    </tr>
    </table>
    
    </body>
    
    </html>
    Last edited by eWish; Nov 21 '08, 05:48 AM. Reason: Please use code tags
  • serdar
    New Member
    • Nov 2008
    • 88

    #2
    Your problem is caused by 'event bubbling'. Read this article.

    Comment

    • clain
      New Member
      • Feb 2007
      • 79

      #3
      the outer div is the parent of inner div... in the sense.. whatever you do inside inner div is also effect the outer div events cos its already an event of outer div by position.

      Comment

      Working...