0

How can i link JavaScript to html please

9th Sep 2020, 5:07 AM
Ismail Idris
Ismail Idris - avatar
3 Respuestas
+ 7
Before the ending body tag ( </body> ) Add a script tag in which you can have an attribute called src which tells html that where to look for that js file. <script src="main.js"></script> Now if u have main.js in the same directory as index.html, they both r linked. in sololearn you don't need to link both files though.
9th Sep 2020, 5:15 AM
maf
maf - avatar
+ 3
Ismail Idris can you clarify your question as there are various ways to link JavaScript to HTML ... here is one example: https://code.sololearn.com/W6bDfp1m5kTp/?ref=app
9th Sep 2020, 5:14 AM
BroFar
BroFar - avatar
+ 1
Thanks for the correction.
9th Sep 2020, 5:19 AM
Ismail Idris
Ismail Idris - avatar