top of page

HTML Lecture 12 - HTML Javascript

  • Writer: Alex Wright
    Alex Wright
  • Oct 21, 2020
  • 1 min read

Updated: Jul 1, 2022



HTML Javascript


Javascript makes your webpage more dynamic and interactive for users. We will be discussing this topic in detail in Javascript lectures. This lecture is just going to give you a taste of what Javascript is and how it makes the web page more interactive.

We use <script> tag to define a client-side Javascript. Common uses for JavaScript are image manipulation, form validation, and dynamic changes of content. To apply Javascript to an HTML element we use document.getElementById() method. Lets see the below code:


<!DOCTYPE html>
<html>
<head>
<title>Lecture 12</title>

</head>
<body>

<h1 style="text-align:center">Lecture 12</h1>

<h2>Current time</h2>
<button type="button" onclick="myFunction()">Click Me</button>
<p id="time"></p>

<script>
function myFunction() {
  document.getElementById("time").innerHTML = Date();      
}
</script>

</body>
</html>

The result:

As we see in this program, we have created a button, which on click displays the current time. The 'onclick' is the button attribute that calls a function to execute when the button is clicked. There is a lot more we can do with Javascript, we will be discussing this topic in more detail in Javascript Lectures.

This is the Final Lecture on HTML!

Comments


bottom of page