<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>innerHTML</title>
</head>
<body>
<h2 id="con">javascript</H2>
<script type="text/javascript">
var mychar=document.getElementById("con");
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello World";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
</body>
</html>
mychar.innerHTML="Hello World";在写之前,第一行是javascript;写上之后运行,变成了Hello World;是不是说明,将mychar修改的值也返给了con?那么,js里代码并不是按顺序运行的咯?
cai鸟
相关分类