<!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>
你的p段那个标签内容只有JavaSprict啊
感觉都是漏洞
form 标签没有封闭;
input 标签没有封闭;
text/javascript 拼写错误。
有一句代码写错了,应该是<script type="text/javascript">