June 2025
Beginner
817 pages
31h 30m
English
As you’ve already learned, you can use JavaScript to access the individual nodes of the DOM. For this, DOM provides various methods and properties for each object in the DOM tree. Here’s a short example that demonstrates the interaction of the programming interface of the DOM with a method and a property. First the HTML code:
<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>DOM interfaces</title></head><body> <h1>The DOM interface</h1> <p>The paragraph text</p> <script src="js/script.js"></script></body></html>
Listing 19.1 /examples/chapter019/19_3/index.html
And here’s the JavaScript code:
let text = document.querySelector('p').innerHTML;if (text) { text += " " + "has been extended!"; document ...
Read now
Unlock full access