0

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

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Baradaran
-1

Like this ?

<html>
  <head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function() {
        $("#wrapper").hover(
           function () {
             $(this).toggleClass("blue");
           }, 
           function () {
             $(this).toggleClass("blue");
           }
         );
      });
    </script>
    <style type="text/css">
      #wrapper {
        background-color: #ccc;
      }
      #wrapper.blue {
        background-color: #ccf;
      }
    </style>
  </head>
  <body>
    <div id="wrapper">
      <p>date</p>
      <p>description</p>
    </div>
  </body>
</html>

Edited by pritaeas: tabs to spaces

0

Great, thank you for the quick reply, working perfect. Thank you again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.