我在简单的代码中触发了,getelementbyid.innerHtml在html页面中。请帮帮我。 在html中使用getelementbyid获取空类型的错误
<!doctype html>
<html lang="en">
\t <head>
\t \t <title>Dom examples</title>
\t \t <script>
\t \t \t var code = document.getElementById("one").innerHTML;
\t \t \t code = code + " !!";
\t \t \t console.log(code);
\t \t </script>
\t </head>
\t <body>
\t \t <h4> DOM practise page </h4>
\t \t <p id="one"> This page is for practise of DOM model in JS</p>
\t \t <p id="two"> Thank You </p>
\t </body>
</html>
因为元素编号=一个尚未加载 –
你试过'.innerText',而不是'.innerHTML'? – reporter