<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>className属性</title>
<style type="text/css">
input{font-size:10px;}
.one{
font-size:20px;
width:230px;
color:red;
}
.two{
font-size:50px;
color:blue;
}
</style>
</head>
<body>
<p id="con" class="one" > JavaScript。</p>
<form>
<input type="button" value="点击更改" onclick="modifyclass"/>
</form>
<script type="text/javascript">
var mychar = document.getElementById("con");
document.write("P元素Class值为:"+mychar.className);
function modifyclass(){
mychar.className="two";
}
</script>
</body>
</html>
为什么我按按钮没有反应
你那个点击更改后面缺少了();应该是onclick="modifyclass();