Curriculum
Course: JavaScript Basic
Login

Curriculum

JavaScript Basic

JSHome

0/216
Text lesson

JS Where To

The <script> Tag

JavaScript code is placed within <script> and </script> tags in HTML.

Example

<script>
document.getElementById(“demo”).innerHTML = “My First JavaScript”;
</script>

While old JavaScript examples might include a type attribute like <script type=”text/javascript”>, it’s important to note that this attribute is optional. JavaScript serves as the default scripting language in HTML.

JavaScript Functions and Events

A JavaScript function comprises a set of JavaScript instructions that are executed upon invocation. For instance, a function may be triggered by an event such as a user clicking a button.

You will discover much more about functions and events in the upcoming chapters.