...

View Full Version : Accesing classes by their name?



Garadon
03-20-2004, 12:59 PM
as the the subject says can it be done?

A1ien51
03-20-2004, 03:25 PM
try using className

Mr J
03-20-2004, 03:26 PM
Yes


document.getElementById(id).className

Garadon
03-20-2004, 04:14 PM
className don't access the class at all it access and elements class attribute nothing more nothing less

liorean
03-20-2004, 04:21 PM
Garadon: There's no easy way. Have a look at: <http://codingforums.com/showthread.php?s=&threadid=26742>

Garadon
03-20-2004, 04:51 PM
that thread is about getting elements by their class name. I wanted to access a class by it name:

example pseudo code:

<style>
.Class1{
font-size:10px;
}
</style>
<script>
alert(document.getClassByName('Class1').fontSize)
</script>

liorean
03-20-2004, 04:59 PM
Oh, DOM2CSS then. Note that this area is quirky. Ie use a proprietary model, inoperable with DOM2CSS. Saf and konq has a not-entirely-working model, op7 doesn't at all support it, but moz has pretty good DOM2CSS support.

Have a look at <http://www.quirksmode.org/> for support tables.

In short, it's easier to change the style property of each element belong ing to the class, or at least better supported.

brothercake
03-20-2004, 06:03 PM
This thread has the basics of DOM 2 CSS http://www.codingforums.com/showthread.php?s=&threadid=14259



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum