Write the syntax of javascript with a code to demonstrate it?


JavaScript Tags

The html script tag wants the browser to get a script between them. We can expect the scripts to be in the following places.

 1.The script can be placed in html's head tag

 2.Within Html's body tag. 

3.As an external file.

 Most importantly client side scripts such as JavaScript are placed in script tags.

demonstration code 

 Live Demo

<html>
<body>
<p>This example writes "JavaScript is not java" into an HTML element with id="script"</p>
<p id="imp"></p>
<script>
   document.getElementById("imp").innerHTML = "JavaScript is not java";
</script>
</body>
</html>

Output

This example writes "JavaScript is not java" into an HTML element with id="script"
JavaScript is not java

Explanation

Every JavaScript code should be in the script tag, if not the code wont execute.In the above example using attribute id the code has executed as "JavaScript is not java". 

Updated on: 30-Jul-2019

110 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements