[Javascript] Javascript arrays

Hakan Magnusson hakan at backbase.com
Fri May 7 02:47:09 CDT 2004


This is perfectly valid:

<div class="cssSelected cssEnabled">

The div will then use both classes, and on duplicate properties the 
class you defined last (cssEnabled, in this case) will have predecence.

Setting classes in JavaScript is really easy.

element.className = 'cssSelected cssEnabled';

Hope it's some help.

Regards,
H


Mike Dougherty wrote:
> It's more like this:
> cssSelected {font-weight: bold;}
> cssDeselected {font-weight: normal;}
> 
> cssEnabled {background-color: black;}
> cssDisabled {background-color: gray;}
> 
> How to change an object to Enabled&Selected from Enabled&Deselected if 
> an object can have only one class?
> 
> you could do 4 classes:  cssEnSel, cssEnDes, cssDiSel, cssDiDes
> but with 2^n classes for each object (n=variable properties) the style 
> sheet will be longer than the html document.
> 
> 
> On Thu, 6 May 2004 10:33:06 -0300
>  "Flavio Gomes" <flavio at economisa.com.br> wrote:
> 
>>  cssSelected {background-color: red; font-weight: bold; }
>>  cssDeselected {background-color: black; font-weight: normal; }
>>
>> -- 
>> Flavio Gomes
>> flavio at economisa.com.br
>>
>> ----- Original Message ----- From: "Mike Dougherty" <mdougherty at pbp.com>
>> To: "[JavaScript List]" <javascript at LaTech.edu>
>> Sent: Thursday, May 06, 2004 10:12 AM
>> Subject: Re: [Javascript] Javascript arrays
>>
>>
>>> >Rather than explictly changing an element's backgroundColor in
>>
>> Javascript, I recommend that you
>>
>>> >change its className instead, and set the color specifics in your
>>
>> stylesheet.  If you can confine
>>
>>> >as many of your stylistic effects as possible to css, you'll always 
>>> know
>>
>> where to go to tweak the
>>
>>> >cosmetic and you won't have to worry about css/javascript conflicts.
>>>
>>>    How do you deal with multiple properties using that strategy?  If i
>>
>> want to change both the
>>
>>> background color (for enable/disable) and font-weight (for
>>
>> select/deselect) - is there a way to
>>
>>> use CSS class, without having to define 4 classes for this one object?
>>>
>>>    I like the idea of controlling display with css, but taking 
>>> everything
>>
>> "out" to the style sheet
>>
>>> makes the inline code a bit less readable.  (ok, so i'm lazy too)
>>> _______________________________________________
>>> Javascript mailing list
>>> Javascript at LaTech.edu
>>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>>
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 



More information about the Javascript mailing list