Javascript Syntax


The script tag

To use JavaScript in HTML, need to use the <script> tag, and define the type attribute is text/javascript

<script type="text/javascript">
alert("Prompt text");
</script>

JavaScript code is usually used in conjunction with HTML code, because JavaScript is inherently to make up for the defects of HTML. Here is an example of how JavaScript and HTML code can be used together:

<html>
  <head>
    <script type="text/javascript">
      alert("Text");
    </script>
  </head>
  <body>
     <div>Contents</div>
  </body>
</html>



Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.
TwitterGoogle+Facebook