未捕获的TypeError:innerHTML属性

时间:2017-05-30 11:02:33

标签: html

HTML文件 -

<!doctype html>
<html lang="en">
 <head>
    <meta charset="utf-8">
     <title>Movies</title>
     <script src="practise.js"></script>
 </head>
 <body>
     <h1>Movie Showtimes</h1>

     <h2 id="movie1">Plan 9 from Outer Space</h2>

     <p>Playing at 3:00pm, 7:00pm.
         <span>
         Special showing tonight at <em>midnight</em>!
         </span>
     </p>
     <h2 id="movie2">Forbidden Planet</h2>

     <p>Playing at 5:00pm, 9:00pm.</p>
 </body>
</html>

JavaScript文件 -

  var planet = document.getElementById("movie2");
  planet.innerHTML = "Red Alert: hit by phaser fire!";

问题出在哪里? 它显示了Uncaught TypeError:无法设置null的属性'innerHTML'。 谁能告诉我问题在哪里?

0 个答案:

没有答案