Chào mọi người!
Mình gặp lỗi khi chạy thử ví dụ của firefox như sau:
Uncaught TypeError: Cannot set property 'textContent' of null
at main.js:3
HTML:
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<script src="scripts/main.js"></script>
<h1>Mozilla is cool</h1>
<img src="images/firefox.jpg" alt="The firefox logo">
<p id="demo">At Mozilla, we're a global communicate of: </p>
<ul>
<li>technologist</li>
<li>thinkers</li>
<li>builders</li>
</ul>
<p>working together to keep the Internet alive and accessible, so people worldwide can be informed contributors and creators of the Web. We believe this act of human collaboration across an open platform is essential to individual growth and our collective future</p>
<p>Read the <a href="#">Mozilla Mainifesto</a>to learn even more about the values and principles that guide the pursuit of our missions.</p>
</body>
</html>
Script:
/*eslint-env browser*/
var myHeading = document.querySelector('h1');
myHeading.textContent = 'Hello world!';
Làm sao để khắc phục lỗi trên? Cảm ơn!