class="classA classB" + this.className="classC" means you wiped classA too?

class="classA classB" + this.className="classC" means you wiped classA too?

Post by peter.kin » Tue, 11 Nov 2003 18:48:14


if you assign multiple classes in order to keep your classes generic
e.g
.classA { position.absolute; left:5 top:5 height:200 width:800 }
.classB { background-color: red}
.classC { background-color: green}

<div id="div1" class="classA classB" ...

but then want to dynamically assign a new class

onMouseOver="this.className='classC'" or onMouseover="changeclass(div1,classC)"

does classC replace BOTH the other classes?

If so can you go:

onMouseOver="this.className='classA classC'"

or what?

can't find any answers to this question via google. thanx

peter

p.s
seems to me that class assignment would be better as an array

eg p."id"[1]=class

also there isn' much scope for encapsulation or inheritance as
 
 
 

class="classA classB" + this.className="classC" means you wiped classA too?

Post by Evertjan » Tue, 11 Nov 2003 19:20:45

Peter King wrote on 10 nov 2003 in
comp.infosystems.www.authoring.stylesheets:


try:

==================

<style>
.classA {color:green;width:250px;}
.classB {font-size:20pt;}
.classC {background-color:red;}
</style>

<div class="classA classB"
onMouseOver="this.oldClasses=this.className;this.className+=' classC'"
onMouseOut="this.className=this.oldClasses">
TEST
</div>

<br>

<div class="classA classC"
onMouseOver="this.oldClasses=this.className;this.className+=' classB'"
onMouseOut="this.className=this.oldClasses">
ME
</div>

==================

IE6 tested

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)