Horje

Full Example of The HTML <script> Element in head

The following JavaScript writes "Hello JavaScript!" into an HTML element with id="demo":
index.html
Example: HTML
<!DOCTYPE html>
<html>
<head>
  <title>Page Title</title>
  <script>
  function myFunction() {
    document.getElementById("demo").innerHTML = "Hello JavaScript!";
  }
  </script>
</head>
<body>

<h1>My Web Page</h1>
<p id="demo">A Paragraph</p>
<button type="button" onclick="myFunction()">Try it</button>

</body>
</html>

Output should be:

Full Example of The HTML <script> Element in head



Related Articles
What is HTML - The Head Element HTML - The Head Element
How to create The HTML <head> Element HTML - The Head Element
How to create The HTML <title> Element in <Head> HTML - The Head Element
How to create The HTML <style> Element in <head> HTML - The Head Element
How to create The HTML <link> Element in <head> HTML - The Head Element
How to create The HTML <meta> Element in Head HTML - The Head Element
What is The HTML Viewport in Head HTML - The Head Element
How to use HTML Viewport in Head HTML - The Head Element
How to create The HTML <script> Element in head HTML - The Head Element
How to create The HTML <base> Element in head HTML - The Head Element

Single Articles
How is to look HTML Input Type CheckboxHTML - The Head Element
Full Code Example of HTML Input Type CheckboxHTML - The Head Element

Type:
Html
Category:
Web Tutorial
Sub Category:
HTML - The Head Element
Uploaded by:
Admin



Share on: