Click here to Skip to main content
15,879,239 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I try this , but it's not working:
CSS
body.defualt{
background-color:blue;
}
body.spring {
background-color : pink;
background-image : url(..);
........
}
...


html
<body name="home" class="default">
  ...
<input type=button value="change"  önclick="change(spring)"/>


JS
function change(theme)
{
document.getElementsByName("home").style.class = theme;
}


note: I used ById first but I read that's only supported in IE and I'm using firefox so I changed to ByName .. though I also used ByTagName

so I guess the problem is withing style.class !!
I'm no sure this is the correct syntax to get to the class attribute
Posted
Comments
Sunasara Imdadhusen 4-Mar-11 8:06am    
You need to change class of BODY?
fresh_girl 4-Mar-11 8:24am    
body and <a> but it would be the same method , right?

1 solution

Hi
Use following

C#
function change(theme)
{
document.body.className = theme;
}


Thanks,
Imdadhusen
 
Share this answer
 
Comments
fresh_girl 4-Mar-11 8:28am    
thanks alot, but that only works on body tag , right??
I have also a.spring{} that I need to change into

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900