JavaScript Starting and Ending with Script Tags <Script>
Tags Starting with <script type = text/javascript> and ending with </script>.
Syntax of JavaScript:
JavaScript can be placed in various locations in HTML such as Place between the Head Part and body
Example for Placing JavaScript- Head part in the HTML
JavaScript output to a page is document.write. The document.write command takes the argument as the text required for producing output.
Tags Starting with <script type = text/javascript> and ending with </script>.
Syntax of JavaScript:
<html> <body> <script type="text/javascript"> ... //Place the JavaScript code </script> </body> </html>
JavaScript can be placed in various locations in HTML such as Place between the Head Part and body
Example for Placing JavaScript- Head part in the HTML
<html> <head> <script type="text/javascript"> ..... ..... // HEAD Section JavaScript </script> </head> <body> </body> </html>Example for Placing JavaScript- Body part in the HTML
<html> <head> </head> <body> <script type="text/javascript"> ..... ..... //BODY Section JavaScript </script> </body> </html>Example for Placing JavaScript on Both Places Head, Body part in the HTML
<html>
<head>
<script type="text/javascript">
// HEAD Section JavaScript
document.write("JavaScript placed in HEAD Section")
</script>
</head>
<body>
<script type="text/javascript">
// BODY Section JavaScript
document.write("JavaScript placed in BODY Section")
</script>
</body>
</html>
Example for Print values using Write In JavaScript in the HTMLJavaScript output to a page is document.write. The document.write command takes the argument as the text required for producing output.
<html>
<head>
<script type="text/javascript">
// HEAD Section JavaScript
document.write("JavaScript placed in HEAD Section")
</script>
</head>
<body>
<script type="text/javascript">
// BODY Section JavaScript
document.write("JavaScript placed in BODY Section")
</script>
</body>
</html>