慕粉1847419605
2016-12-20 20:56
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
<style>
.one{background:yellow; color:red;}
.two{background:pink; color:green;}
</style>
</head>
<body>
<p Id="ggg" class="one">再看看能不能成功</p>
<form> <input type="button" value="更改外观" onclick="bbb()"/>
</form>
<script type="text/javascript">
var mg=document.getElementById("ggg");
document.write(mg.className);
function bbb(){mg.className="two";
}
</script>
</body>
</html>
谁让你 家 的 I 大写的。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
<style>
input{font-size:10px;}
.one{width:200px; background-color:#FCC;}
.two{font-size:18px;color:#F00;}
</style>
</head>
<body>
<p id="con" class="one">再看看能不能成功</p>
<form> <input type="button" value="更改外观" onclick="modifyclass()"/>
</form>
<script type="text/javascript">
var mychar=document.getElementById('con');
document.write(mychar.className);
function modifyclass()
{mychar.className="two"}
</script>
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
<style>
.one{background:yellow; color:red;}
.two{background:pink; color:green;}
</style>
</head>
<body>
<p id="ggg" class="one">再看看能不能成功</p>
<form> <input type="button" value="更改外观" onclick="bbb()"/>
</form>
<script type="text/javascript">
var mg=document.getElementByid("ggg");
document.write(mg.className);
function bbb(){mg.className="two";
}
</script>
</body>
</html>
求点更改外观后怎么还是one。不应该是two吗
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
<style>
.one{background:yellow; color:red;}
.two{background:pink; color:green;}
</style>
</head>
<body>
<p id="ggg" class="one">再看看能不能成功</p>
<form> <input type="button" value="更改外观" onclick="bbb()"/>
</form>
<script type="text/javascript">
var mg=document.getElementById("ggg");
document.write(mg.className);
function bbb(){mg.className="two";
}
</script>
</body>
</html>
还是不行呀
JavaScript入门篇
739817 学习 · 9566 问题
相似问题