0
Where JavaScript typically placed? Is it is under body tag or head tag? State with reason.
in adding JavaScript to web page section, I get confuse when that same question asked me twice with different answer.
2 Réponses
+ 9
You can place it both in body and head tag, this is the answer to your challenge question.
Main difference is that placing it at the end of your <body> tag (as external file or inside your ".html" file) you will have all your DOM elements loaded.
Placing it in the <head> tag (as external file or inside your ".html" file) you should use an onload (or similar) event to manipulate DOM elements.
Generally, as common practice it is placed in the <head> section.
+ 2
https://www.sololearn.com/discuss/103287/?ref=app
hope this helps