Page 330 - Webapplication11_C11_Flipbook
P. 330
document.write("I love eating pasta and pizza!");
document.write("<br> <br>");
document.writeln("Hello!");
document.writeln("I love eating pasta and pizza!");
</SCRIPT>
</PRE>
</BODY>
</HTML>
Do You Know?
The writeln() method works within <PRE> tag.
Lab Assignment ‘n Activity #Subject Enrichment
Create a JavaScript program to display the following in different lines:
1. Your name, class, best friend(s)’ names
2. Today’s date and time
3. Your best memory
4.13 INTERACTING WITH HTML
Document Object Model (DOM) allows JavaScript to dynamically access, modify, and manipulate web page elements.
The DOM represents the structure of an HTML document as a tree, where each element can be accessed, changed, or
removed using JavaScript. In DOM, every HTML element (like paragraphs, buttons, images) is a branch or leaf that you
can access and modify using JavaScript.
HTML is used to structure web pages, while JavaScript is employed to add interactivity and behavior to them. When a
browser loads an HTML file, JavaScript cannot directly comprehend the HTML document. Instead, it interacts with the
Document Object Model (DOM), which the browser generates based on the HTML.
The DOM serves as a representation of the HTML document, organised in a tree-like structure made up of objects.
While JavaScript does not recognise HTML tags (like <h1>H</h1>), it can understand the corresponding objects (such
as h1) within the DOM.
328 Touchpad Web Applications-XI

