By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,729 Members | 1,343 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,729 IT Pros & Developers. It's quick & easy.

HTML div related problem

P: 1
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

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  5. <title>New Page 1</title>
  6. <script>
  7. var funval;
  8. function setfun()
  9. {
  10.     funval=2;
  11. }
  12. function getfun()
  13. {
  14.     alert(funval);
  15. }
  16. </script>
  17. </head>
  18.  
  19. <body>
  20. <table>
  21. <tr>
  22. <td>
  23.  
  24. <div style="bgcolor=red;cursor:hand" onmouseout="getfun();">
  25. <table>
  26. <tr>
  27. <td>
  28. <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Sunset.jpg"  ></div>
  29. </td>
  30. </tr>
  31. <tr>
  32. <td>
  33. <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Water%20lilies.jpg" onmouseover="setfun();"></div>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td>
  38. <div><img src="../../All%20Users/Documents/My%20Pictures/Sample%20Pictures/Winter.jpg"></div>
  39. </td>
  40. </tr>
  41. </table>
  42.  
  43. </div>
  44. </td>
  45. </tr>
  46. </table>
  47.  
  48. </body>
  49.  
  50. </html>
Nov 21 '08 #1
Share this Question
Share on Google+
2 Replies


P: 88
Your problem is caused by 'event bubbling'. Read this article.
Nov 21 '08 #2

clain
P: 79
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.
Dec 1 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.