onmouseover on parent element

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Feb 2007
Posts: 66
Reputation: Baradaran is an unknown quantity at this point 
Solved Threads: 4
Baradaran Baradaran is offline Offline
Junior Poster in Training

onmouseover on parent element

 
0
  #1
24 Days Ago
Hi,
This is probably a very simple problem, but still it is bugging me for a while. I have tried to google for solutions, but I did not find any.

I have a div containing a few text elements like date and description. I want to change the background-color of the div to a light grey when the mouse is over it. This works fine. The problem: As soon as the mouse is over a child element, the background changes back!

What to do?

I appreciate your help.

Regards,
Ali Baradaran
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 849
Reputation: pritaeas will become famous soon enough pritaeas will become famous soon enough 
Solved Threads: 138
Sponsor
pritaeas's Avatar
pritaeas pritaeas is offline Offline
Practically a Posting Shark
 
-1
  #2
24 Days Ago
Like this ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  4. <script type="text/javascript">
  5. $(document).ready(function() {
  6. $("#wrapper").hover(
  7. function () {
  8. $(this).toggleClass("blue");
  9. },
  10. function () {
  11. $(this).toggleClass("blue");
  12. }
  13. );
  14. });
  15. </script>
  16. <style type="text/css">
  17. #wrapper {
  18. background-color: #ccc;
  19. }
  20. #wrapper.blue {
  21. background-color: #ccf;
  22. }
  23. </style>
  24. </head>
  25. <body>
  26. <div id="wrapper">
  27. <p>date</p>
  28. <p>description</p>
  29. </div>
  30. </body>
  31. </html>
Last edited by pritaeas; 24 Days Ago at 5:12 am. Reason: tabs to spaces
"If it is NOT source, it is NOT software."
-- NASA
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 66
Reputation: Baradaran is an unknown quantity at this point 
Solved Threads: 4
Baradaran Baradaran is offline Offline
Junior Poster in Training
 
0
  #3
24 Days Ago
Great, thank you for the quick reply, working perfect. Thank you again.
Reply With Quote Quick reply to this message  
Reply

Tags
child, onmouseover, parent

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC