JavaScript Events

DOM (Document Object Model):

The Document Object Model (DOM) is a programming API for HTML and XML documents. It defines the logical structure of documents and the way a document is accessed and manipulated.

JavaScript Events:

Events are a part of the Document Object Model (DOM). Every HTML page contains a set of events associated with tags/elements. JavaScript has the ability to deal with those events.
Here are few examples of events:

  • When the user clicks a button
  • Whenever the webpage loads
  • Whenever pressing any key
  • closing a window
  • Mouse Over HTML elements

There are many more events. When these events occur in HTML page, JavaScript can interact with them and perform some action.

Using a simple example, we will call a JavaScript function when the user clicks on the button.

      <script type="text/javascript">
            function mytest() {
               alert("JavaScript Click Test")
      <p>Click the following button and see result</p>   
         <input type="button" onclick="mytest()" value="Click Test" />

Congratulations! Chapter Finished. Learn more about the similar topics:
Exercises & Assignments
No Content Found.
Interview Questions & Answers
No Content Found.