问答详情
源自:3-3 innerHTML 属性

为什么结果是这样的?大神

<!DOCTYPE html>
<html>
<head lang="en">
   <meta charset="UTF-8">
   <title></title>
</head>
<body>
<h2 id ="x">hello </h2>
<script type="text/javascript">
   var name = document.getElementById("x");
   document.write("原标题:"+name.innerHTML+"<br>");
   name.innerHTML = "LOL";
   document.write("修改后的内容:"+ name.innerHTML);
</script>
</body>
</html>


提问者:professor景 2019-03-18 20:34

个回答

  • qq_失眠眠_0
    2019-03-18 21:39:34

    name不能做变量名

  • professor景
    2019-03-18 20:35:12

    https://img1.mukewang.com/5c8f907000012b5807230572.jpgundefined