我的代码如下,
<link id="_484_Portals_0_" rel="stylesheet" type="text/css" href="/484/Portals/0/portal.css" />
<style type="text/css" id="Themes_Select">
Body{background-color: #f1f8fd;}
</style>
<input type="text" id="txtBox">测试</input>
<script type="text/javascript" >
function changeBackground()
{
alert(document.getElementById("Themes_Select").innerHTML);
document.getElementById("Themes_Select").innerHTML = 'Body{background-color: #FFFFFF;} ';
alert(document.getElementById("Themes_Select").innerHTML);
}
</script><input type="button" onClick="changeBackground()" Value="change"></input>
想法就是要通过js更换Themes_Select代码段里边的值,这里'Body{background-color: #FFFFFF;} ';可能是多行值,谢谢
<link id="_484_Portals_0_" rel="stylesheet" type="text/css" href="/484/Portals/0/portal.css" />
<style type="text/css" id="Themes_Select">
Body{background-color: #f1f8fd;}
</style>
<input type="text" id="txtBox">测试</input>
<script type="text/javascript" >
function changeBackground()
{
alert(document.getElementById("Themes_Select").innerHTML);
document.getElementById("Themes_Select").innerHTML = 'Body{background-color: #FFFFFF;} ';
alert(document.getElementById("Themes_Select").innerHTML);
}
</script><input type="button" onClick="changeBackground()" Value="change"></input>
想法就是要通过js更换Themes_Select代码段里边的值,这里'Body{background-color: #FFFFFF;} ';可能是多行值,谢谢
<style type="text/css" id="Themes_Select">
Body{background-color: #f1f8fd;}
A:link, A:active, A:visited,
A.CommandButton:link, A.CommandButton:visited, A.CommandButton:active
{color: #666666;}
</style>
<input type="text" id="txtBox">测试</input>
<script type="text/javascript" >
function changeBackground()
{
alert(document.getElementById("Themes_Select").innerHTML);
document.getElementById("Themes_Select").innerHTML = 'Body{background-color: #FFFFFF;} ';
alert(document.getElementById("Themes_Select").innerHTML);
}
</script><input type="button" onClick="changeBackground()" Value="change"></input>
<html>
<head>
<style type="text/css">
body{background: #f1f8fd;}
A:link, A:active, A:visited,
A.CommandButton:link, A.CommandButton:visited, A.CommandButton:active
{color: #666666;}
</style>
</head>
<body>
<script language="JavaScript">
function changecss(theClass,element,value)
{
var cssRules;
if (document.all)
{
cssRules = 'rules';
}
else if (document.getElementById)
{
cssRules = 'cssRules';
}
for (var S = 0; S < document.styleSheets.length; S++)
{
for (var R = 0; R < document.styleSheets[S][cssRules].length; R++)
{
if (document.styleSheets[S][cssRules][R].selectorText == theClass)
{
document.styleSheets[S][cssRules][R].style[element] = value;
}
}
}
}
</script>
<a href="#">test</a>
<input type="button" onClick="changecss('BODY','background','blue');changecss('A:link','color','red')" Value="change"></input>
</body>
</html>