Skip to content

Commit d4ace0c

Browse files
committed
more about DOM
1 parent 31a2a65 commit d4ace0c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

Courses/IBM-JavaScript-Essentials/README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,6 +1383,16 @@ console.log("hello world");
13831383

13841384
The document object model, or DOM, is a programming interface for web documents. It represents the web page so that programs like JavaScript can change the document structure, content, and style. It provides a structured representation of the web page, making it easier for developers to interact with and manipulate web content.
13851385

1386+
1. The DOM allows developers to swiftly respond to user actions in real time with JavaScript. Developers leverage the DOM to access and modify page content and structure.
1387+
1388+
2. The DOM bridges browser differences, ensuring consistent functionality across various platforms and simplifying cross-browser compatibility.
1389+
1390+
3. The DOM facilitates real-time content updates without requiring a full page refresh.
1391+
1392+
4. The DOM allows developers to attach event listeners to the elements, enabling them to respond to user interactions.
1393+
1394+
5. The DOM supports assistive technologies like screen readers and ensures inclusivity for users with disabilities. Dynamic and interactive features facilitated by the DOM, contribute to an improved user experience.
1395+
13861396
- Document:
13871397

13881398
1. The term document refers to a web page or any XML document such as HTML, XHTML, or XML.
@@ -1419,7 +1429,17 @@ documentNode; // You will be able to see the entire document object.
14191429

14201430
2. Element nodes represent HTML elements such as div, p, a, and form the bulk of the DOM structure. To access the element node select the paragraph you want to inspect and select inspect. then navigate to the console tab and enter $0. It will output the HTML code and details of that specific element.
14211431

1422-
3. Attribute nodes represent attributes of HTML elements including id, class, and src.
1432+
3. Attribute nodes represent attributes of HTML elements including id, class etc and provide additional information about an element. To access the attributes, select the anchor tag you want to inspect and select inspect then navigate to the console tab and enter $0 getAttribute("href"); command. this will give you the link inside href.
1433+
1434+
```js
1435+
$0 getAttribute("href") // https://www.example.com
1436+
```
1437+
1438+
You can also change the values of the attributes or modify them using this command.
1439+
1440+
```js
1441+
$0.getAttribute("href", "https://www.updated.com");
1442+
```
14231443

14241444
4. Text nodes contain the text content within elements. To retrieve the text of the selected element, use the $0.textContent command. This will give the text content.
14251445

0 commit comments

Comments
 (0)