Sunday 30 September 2018

JavaScript: DOM: Document object model

DOM stands for Document object model. DOM represent HTML document as tree, called as DOM tree.

For example

sample.html
<!DOCTYPE html>

<html>

<head>
    <title>DOM Tree Example</title>
</head>

<body>
    <h1>Simple DOM Tree</h1>

    <p><span>Hello Wolrd</span></p>
</body>

</html>

Above sample.html is internally represented like below.


html: Is the root element.
head, body: these are siblings, since these share common parent html.
title: It is the child of the element head and grand child for element html.


What Can I do using DOM?
a.   By using DOM, you can build documents (HTML, XML etc.,)
b.   Navigate through the document
c.   You can add, modify, or delete elements and content in the document.

What is document object?
The object that handles the contents of a webpage is called document.





Previous                                                 Next                                                 Home

No comments:

Post a Comment