输出的结果只有 JavaScript
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>calssName属性</title>
<style type="text/css">
input{
font-size: 10px;
}
.one{
width: 200px;
background-color: #CCC;
}
.two{
font-size: 18px;
color:#F00;
}
</style>
</head>
<body>
<p id = "con" class="one">JavaSprict<p>
<form
input type = "button" value = "点击更改" onclick="modifyclass()" >
</form>
<script type = "text/javasprit">
var mychar = document.getElementById("con");
document.write("p元素calss值为:"+mychar.className+"<br/>");//输出p元素给的属性
function modifyclass(){
mychar.className = "two";//改变className
}
</script>
</body>
</html>