Page 159 - Computer Software Application TP - Volume 1
P. 159
COMPUTER SOFTWARE APPLICATION - CITS
console.log(person2.fullName()); // Output: Jane Smith
</script>
</body>
</html>
3 Save the program as a .html file
4 Open the html file with a web browser
5 Go to the browsers console tab and verify the output.
TASK 2: Using Document Object Model
1 Open the text editor
2 Write the following codes
<html >
<head>
<title>DOM Example</title>
</head>
<body>
<h1 id=”heading”>DOM Example</h1>
<p id=”paragraph”>This is a paragraph.</p>
<button onclick=”changeColor()”>Change Color</button>
<script>
// Function to change the color of the heading
function changeColor() {
var heading = document.getElementById(‘heading’);
heading.style.color = ‘blue’;
}
</script>
</body>
</html>
144
CITS : IT & ITES - Computer Software Application - Exercise 40