<script> JS goes here </script>
.js. In order to use this file, you need to import it inside the HTML. You can do this by using a script tag.
Let's see this with the help of an example.
// index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="script.js"></script> <title>Ecdysis</title> </head> <body> <p id="text"></p> </body> </html>
// script.js document.getElementById("text").innerHTML = "This is a paragraph tag";
We can solve this error in two ways:
- Using Async and Defer
<script src="script.js" defer></script>