+ 3

How to link html file to js file.(not in sololearn.)

1st Jun 2021, 1:56 PM
Aditya Dhiman
Aditya Dhiman - avatar
8 Réponses
+ 8
you could place 'script' tag at any place of your html code... the only things to be aware are: + if 'src' attribute is provided, any code ocurring inside it will never be executed (only the linked js file through the 'src' path provided will be loaded and executed) + js will load synchronously per default (parsing is stopped, until the script has been loaded and run), so if you need to access DOM inside it, you must either place it after the targeted elements or differ the execution of the DOM access... https://code.sololearn.com/WZ52Wv4rqxXs/?ref=app also, in sololearn (at least android) app', the JS tab is inserted at <head> start... while in sololearn website, it's inserted at <body> end ^^
1st Jun 2021, 6:20 PM
visph
visph - avatar
+ 4
Between which tags
1st Jun 2021, 3:49 PM
Aditya Dhiman
Aditya Dhiman - avatar
+ 3
Using script tag....with src attribute
3rd Jun 2021, 2:20 AM
Surya Magesh
Surya Magesh - avatar
+ 1
Use script tag and place the url of js file in sec attributes, and place it inside head tag (prefer to write in last line of head tag); Just like we link jQuery to our html file
3rd Jun 2021, 1:38 PM
Aayush-droid
Aayush-droid - avatar
+ 1
Use <link href=".js" rel="script"> or Use <script> and write the code in between the opening and closing tags.
16th Apr 2023, 7:19 PM
Nguyen Tran
Nguyen Tran - avatar
0
<a href="js">js<\a>
3rd Jun 2021, 9:48 AM
Micheal Alfred