DHTML stands for Dynamic HTML. Dynamic means that the content of the web page can be customized or changed according to user inputs i.e. a page that is interactive with the user. In earlier times, HTML was used to create a static page. It only defined the structure of the content that was displayed on the page. With the help of CSS, we can beautify the HTML page by changing various properties like text size, background color etc. The HTML and CSS could manage to navigate between static pages but couldn’t do anything else. If 1000 users view a page that had their information for eg. Admit card then there was a problem because 1000 static pages for this application build to work. As the number of users increase, the problem also increases and at some point it becomes impossible to handle this problem.
- Performing html tasks
- Performing CSS tasks
- Handling events
- Validating inputs
Explanation: In the above example, change the text of paragraph which using id. Document is an object of html that is displayed in the current window or object of DOM. The getElementById(id) gives the element id. The innerHTML defines the content within the id element. The id attribute is used to change HTML document and its property. Paragraph content changed by document id. For example: document.getElementById(“geeks”).style.color = “blue”; It is used to set the paragraph color using id of elements.
Example 2: Creating an alert on click of a button.
Explanation: In this example, creating a function that will be invoked on click of a button and it changes the color of text and display the alert on the screen. window is an object of current window whose inbuilt method alert() is invoked in Click() function.
Explanation: In this example, make a validate() function which ensures the user is illegible or not. If user enters > 60 then selected otherwise not selected.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.