Try using the .hover() method instead. http://docs.jquery.com/Events/hover#overout
From the docs:
Additionally, checks are in place to see if the mouse is still within the specified element itself (for example, an image inside of a div), and if it is, it will continue to 'hover', and not move out (a common error in using a mouseout event handler).
You could also use .bind('mouseenter', fn) and .bind('mouseleave', fn) , but .hover(fn, fn) is usually more convenient
--Karl ____________ Karl Swedberg www.englishrules.com www.learningjquery.com On Nov 19, 2008, at 10:03 AM, [EMAIL PROTECTED] wrote:
Hi, I'm trying to highlights elements of the page on mouseover. I want to highlight all td's h1's and p's when the mouse is over. $("td, h1, p").mouseover(function() { $(this).css("backgroundColor", "CCCCCC"); }); $("p, h1, td").mouseout(function() { $(this).css("backgroundColor", mObj.prevBGColor); }); That doesn't do what I want. Indeed if a <p> is inside a <td>, only the td gets highlighted (or maybe the p too, but then since the td is also hightlighted, it doesn't look right) How can I specify that only top element should be highlighted ? Thanks