求點更改外觀后怎么還是one。不應(yīng)該是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>
2016-12-20
誰讓你 ? 家 ?的 ? ?I ? 大寫的。
2016-12-20
<!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>
2016-12-20
<!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>
2016-12-20
求點更改外觀后怎么還是one。不應(yīng)該是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>
還是不行呀