若我如风
2017-09-09 21:32
<h2 id="con">I love JavaScript</H2>
<script type="text/javascript">
var mychar= document.getElementById("con");
mychar.style.color = "red";
maychar.innerHTML = "I LOVE YOU";
document.write(maychar);
</script>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
</head>
<body>
<h2 id="con">I love JavaScript</h2>
<script type="text/javascript">
var mychar= document.getElementById("con");
mychar.style.color = "red";
mychar.innerHTML = "I LOVE YOU";
document.write(mychar.innerHTML);
</script>
</body>
</html>
第一个错误maychar.innerHTML 多了个a;第二个,最好把脚本写在body后面,这是个好习惯,写在前面最好加window.onload
maychar.innerHTML = "I LOVE YOU";
maychar多了个y,会不会是这个错误。
JavaScript入门篇
739817 学习 · 9566 问题
相似问题