How to Place JavaScript code in Head

Javascript / Overview of Javascript

225

Program:

<!DOCTYPE html>
<html>
<head>
<script>
function myFunction() {
  document.getElementById("demo").innerHTML = "Paragraph changed.";
}
</script>
</head>
<body>

<h2>Place your JavaScript code in Head</h2>

<p id="demo">This is a Paragraph.</p>

<button type="button" onclick="myFunction()">Check it</button>

</body>
</html> 

Output:

Run above code

Explanation:

No

This Particular section is dedicated to Programs only. If you want learn more about Javascript. Then you can visit below links to get more depth on this subject.