HTML Javascript


Javascript in HTML is used to make HTML responsive.Javascript can fully change the HTML document.
Content between tags <script> and </script> is known as javascript.

Displaying text using javascript

<!DOCTYPE html>
<html>
<head>
<title>
HTML Javascript
</title>
</head>
<body>
<p>Demo of Javascript in HTML.</p>
<p id="javas">
</p>
<script>
documnet.getElementById("javas")
.innerHTML="World is great place.!";
</script>
</body>
</html>

Output:

Demo of javascript in HTML.

Changing HTML content using Javascript

Example:

<!DOCTYPE html>
<html>
<head>
<title>
HTML Javascript
</title>
</head>
<body>
<button type="button" onclick="myFunction()"> Click Me!</button>
<p id="jav">
World is great place.
</p>
<script>
function myFunction(){
document.getElementById("jav")
.innerHTML="World is large place but abit occupied.";
}
</script>
</body>
</html>

Output:

Click the button and see what happens after clicking.

World is great place.

You can know more about HTML Javascript in our JAVASCRIPT tutorial.