| | |
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:
Solved Threads: 4
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
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
-1
#2 24 Days Ago
Like this ?
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<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>
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
-- NASA
![]() |
Similar Threads
- Javascript Issue (Changing background of parent element on onmouseover) (JavaScript / DHTML / AJAX)
- Creating a popup menu on mouse over (JavaScript / DHTML / AJAX)
- remove element (JavaScript / DHTML / AJAX)
- Add image uploading to post options (Growing an Online Community)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: List Items
- Next Thread: how do i make a simple scrollbar with javascript and css
| Thread Tools | Search this Thread |






