Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > CSS and javascript interaction

Reply
Thread Tools

CSS and javascript interaction

 
 
RHO
Guest
Posts: n/a
 
      09-25-2003
Hi,

I have a table with alternating bg-colors and in which I highlight the row
focused by the mouse. This is achieved by

<TR bgcolor='#A7BCCF' onmouseout="this.bgColor = '#A7BCCF'"
onmouseover="this.bgColor = '#86B1DC'">
<TD> Something ...
<TR bgcolor='#B8CADA' onmouseout="this.bgColor = '#A7BCCF'"
onmouseover="this.bgColor = '#86B1DC'">
<TD> Something else ...

THis works fine. If however I use CSS <TD class='myclass'> the
onmouseXXX-effect disappears. Any suggestions as how to resolve this ?

RHO


 
Reply With Quote
 
 
 
 
Dom Leonard
Guest
Posts: n/a
 
      09-29-2003
RHO wrote:
> Hi,
>
> I have a table with alternating bg-colors and in which I highlight the row
> focused by the mouse. This is achieved by
>
> <TR bgcolor='#A7BCCF' onmouseout="this.bgColor = '#A7BCCF'"
> onmouseover="this.bgColor = '#86B1DC'">


Okay, you are coding mouseout/mouseover handlers to set bgColor values.
The last time I looked, these are *deprecated* in HTML 4.

> <TD> Something ...
> <TR bgcolor='#B8CADA' onmouseout="this.bgColor = '#A7BCCF'"
> onmouseover="this.bgColor = '#86B1DC'">
> <TD> Something else ...
>
> THis works fine. If however I use CSS <TD class='myclass'> the
> onmouseXXX-effect disappears. Any suggestions as how to resolve this ?


AFIK, the bgColor attributes are from HTML 3, whilst the class attribute
is from HTML 4. This brings into question the notion of specificity.
From your description (untested), the class attribute is taking
precendence over setting values for bgColor which has been replaced by
"background-color" in CSS.

For HTML 4, try something like:

<table>
<TR style="background-color: #B8CADA;"
onmouseout="this.style.backgroundColor = '#A7BCCF'"
onmouseover="this.style.backgroundColor = '#86B1DC'">
<TD> whatever
</TD>
</TR>
</table>

Normally style attributes of an element have higher specificity than
class name rules for the same element.

HTH,

Dom


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript for User interaction. Scamjunk Perl Misc 2 04-28-2006 04:37 PM
[ANN] Orbjson, a JSON-RPC ORB for JavaScript/Ruby interaction James Britt Ruby 6 03-04-2005 05:50 AM
Javascript Interaction with asp.net controls =?Utf-8?B?SXJmYW4gQWtyYW0=?= ASP .Net 7 01-17-2005 02:13 AM
asp.net - javascript form values interaction can asp.net read and write to nonasp forms? David Virgil Hobbs ASP .Net 0 01-06-2004 07:09 AM
Browser/JavaScript Interaction James Howe Javascript 0 09-13-2003 03:37 PM



Advertisments