javescript和CSS样式类 [英] javescript and css style class
本文介绍了javescript和CSS样式类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试了此方法,但是它不起作用:
CSS
I try this , but it''s not working:
CSS
body.defualt{
background-color:blue;
}
body.spring {
background-color : pink;
background-image : url(..);
........
}
...
html
html
<body name="home" class="default">
...
<input type=button value="change" önclick="change(spring)"/>
JS
JS
function change(theme)
{
document.getElementsByName("home").style.class = theme;
}
注意:我首先使用ById,但我读到它仅在IE中受支持,而我使用的是firefox,因此我更改为ByName ..尽管我也使用ByTagName
所以我想问题出在伴有style.class!
我不确定这是获取类属性的正确语法.
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
推荐答案
嗨
使用以下
Hi
Use following
function change(theme)
{
document.body.className = theme;
}
谢谢,
Imdadhusen
Thanks,
Imdadhusen
这篇关于javescript和CSS样式类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文