</> Code Corner

JavaScript · JS Tutorial · Lesson 2

JS Where To

The <script> tag, internal and external scripts.

In HTML, JavaScript code is inserted between <script> and </script> tags. Scripts can be placed in the <head>, in the <body>, or in external files.

Example

<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>

External JavaScript

Example

<script src="myScript.js"></script>

Keep reading “JS Where To”

Sign up to read the full lesson (2 more parts), try every example in the live editor, and take the 5-question quiz.

Chat with us 👋