- Performing html tasks
- Performing CSS tasks
- Handling events
- Validating inputs
Explanation: In the above example, change the text of the paragraph using id. A 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 an 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 the 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 that ensures the user is illegible or not. If the user enters > 60 then selected otherwise not selected.
Please Login to comment...