saftutorials.com
HTML Scripts Tutorial

HTML Script is a HTML tag. By HTML Script tag declare JavaScript code in HTML Pages embedded system. 

Where to use HTML Script tag?

The right way for declaration of HTML Script tag Write your Script tag before </head> tag. If you declare JavaScript in after <body> tag its will be work successfully.

How to use HTML Script tag?

This is structure of HTML Script tag <script>Here your JavaScript code</script>


Basic Structure of HTML Script

<!DOCTYPE html>
<html>
<head>
  <title>HTML Scripts Tutorials</title>
</head>
<body>
<div id="sample"></div>
<script type="text/javascript">
  document.getElementById("sample").innerHTML = "The Sample JavaScript!";
</script>
</body>
</html>

The Sample JavaScript!

HTML JavaScript Alert

<!DOCTYPE html>
<html>
<head>
  <title>HTML Script Tutorials</title>
</head>
<body>
<button onclick="theFunctions()">Click to open Alert</button>
<script>
  function theFunctions() { 
      alert("Hello I am Alert HTML Text!");
} </script> </body> </html>

HTML JavaScript can Change Content

<!DOCTYPE html>
<html>
<head>
  <title>HTML Scripts Tutorials</title>
</head>
<body>
<div id="sample">This is First HTML Text!</div>
<button onclick="theFunctions()">Click to Change HTML Text!</button>
<script>
  function theFunctions() { 
      document.getElementById("sample").innerHTML = "This is Changed HTML Text!";
  }
</script>
</body>
</html>

This is First HTML Text!

HTML JavaScript can Change Content Style

<!DOCTYPE html>
<html>
<head>
  <title>HTML Scripts Tutorials</title>
</head>
<body>
<div id="sample">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</div>
<button onclick="theFunctions()">Click to Change Color</button>
<script>
function theFunctions() { 
    document.getElementById("sample").style.color = "blue";     
}
</script>
</body>
</html>

Lorem ipsum dolor sit amet, consectetur adipisicing elit.
Find us on

Facebook Google Plus Twitter Pinterest YouTube

web statistic