Answer: The HTML DOM is a standard object model and programming interface for HTML. It defines:
- The HTML elements as objects
- The properties of all HTML elements
- The events for all HTML elements
- The methods to access all HTML elements
e.g.
<html>
<head>
<title>Simple HTML</title>
<script type="javascript">
function LoadMeFirst(){
alert("Html Dom loading.....");
}
function ClickME(){
alert("Dom Loaded and hence the button is clicked");
var accessingTheParagraphText = document.getElementsByTagName('p')[0].innerHTML;
}
</script>
</head>
<body onLoad="LoadMeFirst()">
<p>A simple paragraph</p>
<input type="button" id="myButton" value="MyButton" onClick="ClickME()" />
</body>
</html>
In the above example,
- The HTML elements are - HTML,HEAD,TITLE,BODY,P,INPUT
- The button properties are - TYPE,ID,VALUE
- The Event for
a) BODY is: onLoad
b) BUTTON is: onClick
- Method to access the HTML elements - getElementsByTagName
Asked In: Many Interviews |
Alert Moderator