+ 7
How can I put JavaScript in seprate files?
What does this mean? I can't understand it.
3 Respostas
+ 7
Your JS code can either be placed in your HTML file within <script> tags, e.g.
<html>
<head></head>
<body>
<script>console.log("Hello!")</script>
</body>
</html>
or placed in a separate .js file, and then linked in your HTML file (by specifying the .js file location in the script tag src attribute, e.g.
<html>
<head>
<script src = "path/to/myScript.js" type = "text/javascript"></script>
</head>
<body></body>
</html>
+ 4
Now I understand what does this mean! Thnx for your support Hatsey Rei, Divya Mohan.❤
+ 3
Save html file as index.html
And a js file for index.html as myscript.js
In html file head tag use
<link src="myscript.js"></script>
* both file in same folder
For more detail search external js file link to html.
In browser.