写个style样式 变不了颜色,最后还是照着例子mychar.style.color才变得
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>style样式</title>
<style>
#con{
font color="red";
width="300px";
background color="#CCC";
}
</style>
</head>
<body>
<h2 id="con">I love JavaScript</H2>
<p> JavaScript使网页显示动态效果并实现与用户交互功能。</p>
<script type="text/javascript">
var mychar= document.getElementById("con");
mychar.style.color = "red";
mychar.style.backgroundColor = "#ccc";
mychar.style.width = "300px";
</script>
</body>
</html>