FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

acces fieldset class with javascript

 


alalex
is there any way to change the css class od a fieldset with javascript?
i have a fieldset with id example, and i used the document.GetElementById('example'), and stored the aswer in a variable. But then what?? Confused

Help please!!
thanks
mathiaus
Use this line, changing yourvar for what you named your variable in the code you already have, and yournewclass with the name of the new class you want it to have Smile
Code:
yourvar.className=yournewclass;
Ranfaroth
More generaly, you can change every attributes
Code:
my_element.setAttribute("my attribute","its value");
alalex
ok thanks a lot
alalex
wait, when i was trying to do it with those scripts, it threw an error, it said that the object didn't accept that property or method. Here is my code:
Code:
<script language="javascript" type="text/javascript">
function color_fieldset(id_element) {
   var fieldset = document.GetElementById(id_element);
   my_element.setAttribute("class","active");
}
</script>

And then i put the funtion in a onMouseOver in the fieldset, this is the code:
Code:
<fieldset class="normal_field" id="home" onMouseOver="color_fieldset(home)">

Confused Question
mathiaus
You didn't change my_element with the var fieldset Wink
Code:
fieldset.setAttribute("class","active");
alalex
o cool! thanks! i didnt notice.. Confused
Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.