我写的跟范文一模一样为什么出不来效果?

<!DOCTYPE HTML>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>innerHTML</title>

</head>

<body>

<h1 id="con">javascript<h1>

<p>xxx</p>

<script type="text/javascript">

var mychar=document.getElementById("con");

document.write("原来:"+mychar.innerHTML+"<br>");

mychar.innerHTML="HELLO WORLD"

document.write("现在:"mychar.innerHTML);

</script>

</body>


慕先生4277178
浏览 1266回答 1
1回答

guozhchun

document.write("现在:"mychar.innerHTML);   // 这里错了,少了个 '+',应该是:document.write("现在:" + mychar.innerHTML);
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript