top of page

JavaScript can be placed in the <body> and the <head> sections of an HTML page.

 

The <script> Tag

In HTML, JavaScript code must be inserted between <script> and </script> tags.

 

Example

 

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

 

JavaScript Functions and Events

 

A JavaScript function is a block of JavaScript code, that can be executed when "asked" for.

For example, a function can be executed when an event occurs, like when the user clicks a button.

You will learn much more about functions and events in later chapters.

 

JavaScript in <head> or <body>

 

You can place any number of scripts in an HTML document.

Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both.

Incorporating Javascript

Incorporating JavaScript in Your Documents

 

© 2023 BY CODE MODE

  • Facebook Basic Black
  • Twitter Basic Black
  • Instagram Basic Black

codemode2016@gmail.com   |   Chitkara University,HIMUDA Education Hub,Atal                                             |       Nagar,Barotiwala, Distt.-Solan, HP 174-103

bottom of page