How to link html file to js file.(not in sololearn.) | Sololearn: Learn to code for FREE!

+3

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

6/1/2021 1:56:56 PM

.A.D.

7 Answers

New Answer

+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 ^^

+4

Between which tags

+3

Using script tag....with src attribute

+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

0

<a href="js">js<\a>