PDA

View Full Version : Multiple classes!


wickford
08-04-2003, 01:34 PM
How can I add more than one class to a DIV tag?

Both <div class="menu,text"> and <div class="menu" class="text"> fail to work.

Thanks!

ahosang
08-04-2003, 02:14 PM
<html>
<head>
<title>CSS</title>
<style>
.first {
background-color:#ff9999;
}
.second {
text-decoration:underline;
}
.third {
font-style:italic;
}
</style>
</head>

<body>
Test Page<br>
<div class="first second third">Hello World</div>
</body>
</html>

brothercake
08-04-2003, 02:31 PM
Did you want to know how to add/remove it in the DOM?

If so, given <div id="something" class="foo"> you can go

refToDiv.className += ' bar';

and

refToDiv.className = refToDiv.className.replace(/ bar/,'');

jkd
08-04-2003, 06:28 PM
This doesn't have anything really to do with DOM Scripting, so I'll move it to the HTML forum.

wickford
08-07-2003, 12:24 AM
Thanks ahosang, that's exactly what I wanted. :D