为什么还是显示的I love JavaScript
<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>
<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>
2017-09-09
<!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
举报