+ 7

How can I put JavaScript in seprate files?

What does this mean? I can't understand it.

17th Sep 2020, 6:36 AM
Programmer ツ
Programmer ツ - avatar
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>
17th Sep 2020, 6:44 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
Now I understand what does this mean! Thnx for your support Hatsey Rei, Divya Mohan.❤
17th Sep 2020, 6:51 AM
Programmer ツ
Programmer ツ - avatar
+ 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.
17th Sep 2020, 6:46 AM
Divya Mohan
Divya Mohan - avatar