JS中使用className修改样式无效
<html><head><title>LightExr</title><scripttype="text/css">.light{background-color:Whi...
<html>
<head>
<title>Light Exr</title>
<script type="text/css">
.light
{
background-color:White;
}
.dark
{
background-color:Dark;
}
</script>
<script type="text/javascript">
//JS修改样式表(.css),好像没凑效
function openLight()
{
document.body.className="light";
}
function closeLight()
{
document.body.className="dark";
}
</script>
</head>
<body>
<input type="button" value="Open" onclick="openLight()"/>
<input type="button" value="Close" onclick="closeLight()"/>
</body>
</html> 展开
<head>
<title>Light Exr</title>
<script type="text/css">
.light
{
background-color:White;
}
.dark
{
background-color:Dark;
}
</script>
<script type="text/javascript">
//JS修改样式表(.css),好像没凑效
function openLight()
{
document.body.className="light";
}
function closeLight()
{
document.body.className="dark";
}
</script>
</head>
<body>
<input type="button" value="Open" onclick="openLight()"/>
<input type="button" value="Close" onclick="closeLight()"/>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询