(1) Your <script>
tag should be placed before the closing </body>
tag.
((1)您的<script>
标签应放在结束</body>
标签之前。)
Your JavaScript is trying to manipulate HTML elements that haven't been loaded into the DOM yet.(您的JavaScript正在尝试操作尚未加载到DOM中的HTML元素。)
(2) Your assignment of HTML content looks jumbled.((2)您对HTML内容的分配看起来很混乱。)
(3) Be consistent with the case in your element ID, ie 'DIV2' vs 'Div2'((3)与元素ID中的情况一致,即'DIV2'与'Div2')
(4) User lower case for 'document' object (credit: ThatOtherPerson)((4)“文档”对象的用户小写(信用:ThatOtherPerson))
<body>
<div id="DIV1">
// Some content goes here.
</div>
<div id="DIV2">
</div>
<script type="text/javascript">
var MyDiv1 = document.getElementById('DIV1');
var MyDiv2 = document.getElementById('DIV2');
MyDiv2.innerHTML = MyDiv1.innerHTML;
</script>
</body>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…