🗣️ A. Greetings & Introductions
❓ B. Common Questions
💬 C. Common Responses
🤝 D. Polite Expressions
💡 Practice Tip: Speak 5 phrases each morning and 5 at night. Within one week, your pronunciation and confidence will improve fast!
Your blog category
💡 Practice Tip: Speak 5 phrases each morning and 5 at night. Within one week, your pronunciation and confidence will improve fast!
The Document Object Model (DOM) is a programming interface for web documents.
In short: The DOM is not the HTML itself—it’s the in-memory representation of the page that JavaScript interacts with.
When you open a web page:
Example:
<html>
<body>
<h1>Hello</h1>
</body>
</html>
Becomes:
Document
└── html
└── body
└── h1
└── "Hello"
| Node Type | Example | Description |
|---|---|---|
| Document Node | document | The root of the DOM tree. |
| Element Node | <h1>, <p> | HTML tags. |
| Text Node | "Hello World" | The actual text inside elements. |
| Attribute Node | class="title" | The attributes of HTML elements. |
Think of:
document
└── html
├── head
│ ├── meta
│ └── title ("My Page")
└── body
├── h1 ("Welcome")
└── p ("This is my page.")
Graphical version:
Imagine boxes connected with lines:
Examples :
<!DOCTYPE html>
<html>
<body>
<h1> Hello Students </h1>
<h1> Hello Friends </h1>
<p class="t1"> Welcome </p>
<p class="t1"> PSR Eng </p>
<p class="t1"> Sivakasi </p>
<p id="mytitle"> MyCourse</p>
<script type="text/javascript">
let m=document.getElementsByClassName("t1");
console.log(m[0].innerText)
console.log(m[1].innerText)
console.log(m[2].innerText)
let m3=document.getElementById("mytitle");
console.log(m3.innerText);
let myh=document.getElementsByTagName("h1");
console.log(myh[0].innerText);
console.log(myh[1].innerText);
</script>
</body>
</html>
Output :

Example : InnerText and InnerHTML
<!DOCTYPE html>
<html>
<body>
<div id="area1">
<h1> Student Area </h1>
<ul>
<li> 1. Aruna </li>
<li> 2. Kumar </li>
<li>3. Raj </li>
</ul>
</div>
<div id="area2">
<h1> Teachers Area </h1>
</div>
<script type="text/javascript">
let a1=document.getElementById("area1");
console.log(a1.innerText);
console.log(a1.innerHTML);
</script>
</body>
</html>
Output

Example : Inner HTML
<!DOCTYPE html>
<html>
<body>
<div id="area1">
</div>
<div id="area2">
<h1> Teacher Zone </h1>
</div>
<div id="area3">
</div>
<div id="area4">
</div>
<script type="text/javascript">
let a1=document.getElementById("area1");
a1.innerText="Students Zone";
let a2=document.getElementById("area2");
let tcopy=a2.innerText;
console.log(tcopy);
let a3=document.getElementById("area3");
a3.innerText=tcopy;
let myarea=document.getElementById("area4");
myarea.innerHTML="<b>Collage Zone</b>";
</script>
</body>
</html>
Output

Example :

Example :
<!DOCTYPE html>
<html>
<body>
<div id="mytable">
</div>
<script type="text/javascript">
let mytbl=document.getElementById("mytable");
mytbl.innerHTML="<h1>Course Details </h1><h2>Javascript</h2>";
</script>
</body>
</html>
Output

Example
<!DOCTYPE html>
<html>
<body>
<div id="mytable">
Welcome to My Home Page
</div>
<script type="text/javascript">
let mytbl=document.getElementById("mytable");
mytbl.style.color="Red";
mytbl.style.fontSize="20px";
</script>
</body>
</html>
Output :

Example for Events
<!DOCTYPE html>
<html>
<body>
<div id="mytable" tabindex="0">
Welcome to My Home Page
</div>
<script type="text/javascript">
let mytbl=document.getElementById("mytable");
//Common Events
//mytbl.addEventListener("click",
//mytbl.addEventListener("dblclick",
//mytbl.addEventListener("mouseout",
//mytbl.addEventListener("mouseover",
//mytbl.addEventListener("keydown",
//mytbl.addEventListener("keyup",
mytbl.addEventListener("mouseover",
function()
{
mytbl.style.color="Red";
mytbl.style.backgroundColor="Yellow";
mytbl.style.fontSize="20px";
});
mytbl.addEventListener("mouseout",
function()
{
mytbl.style.color="blue";
mytbl.style.backgroundColor="white";
mytbl.style.fontSize="20px";
});
mytbl.addEventListener("keydown",
function()
{
mytbl.style.color="green";
mytbl.style.backgroundColor="orange";
mytbl.style.fontSize="40px";
});
</script>
</body>
</html>

Module 1 – Introduction to the DOM
<p>, <h1>, <div> )id, class, src)📌 Think of DOM as a live copy of your HTML that JavaScript can read and change at any time.
document Objectdocument object represents the entire web page.Example:
<!DOCTYPE html>
<html>
<head>
<title>DOM Example</title>
</head>
<body>
<h1 id="heading">Hello DOM!</h1>
<script>
console.log(document.title);
console.log(document.body);
</script>
</body>
</html>
Teaching Demo:
document.title document.body.style.backgroundColor = "lightblue"✅ Beginner Level
document.body.style.<h1> element in the console.
<html>
<head>
<title> Welcome To Ramakayal Computer Education</title>
<style>
#p1
{
color:blue;
}
#p2
{
color:red;
}
.myarea1
{
background-color:yellow
}
</style>
</head>
<body>
<h1 style='color:red'> My Festivals </h1>
<p id='p1'> There are two prevailing definitions of the lunar month: amānta, where the month ends with the new moon, and pūrṇimānta, where it ends with the full moon.[3] Consequently, the same day may be associated with different but adjoining months. When a festival takes place during śukla paksha (the waxing phase of the moon), both traditions attribute it to the same month. However, if the festival occurs during kṛiṣhṇa paksha (the waning phase of the moon), the two traditions assign it to different, but adjacent months. </p>
<h1> Welcome </h1>
</div>
<script>
document.body.style.backgroundColor="green"
</script>
</body>
</html>
✅ Challenge Level
<p> tag.getElementById()id (must be unique in a page).<p id="myPara">Hello World</p>
<script>
let para = document.getElementById("myPara");
console.log(para.innerText);
</script>
getElementsByClassName()htmlCopyEdit<p class="text">Para 1</p>
<p class="text">Para 2</p>
<script>
let items = document.getElementsByClassName("text");
console.log(items[0].innerText);
</script>
getElementsByTagName()p, div, img, etc.).javascriptCopyEditlet allParas = document.getElementsByTagName("p");
console.log(allParas.length);
querySelector()javascriptCopyEditlet firstPara = document.querySelector(".text");
querySelectorAll()forEach()).javascriptCopyEditlet allItems = document.querySelectorAll(".text");
allItems.forEach(item => console.log(item.innerText));
| Method | Returns | Multiple? | Selector Type |
|---|---|---|---|
getElementById() | Element | No | ID only |
getElementsByClassName() | HTMLCollection | Yes | Class only |
getElementsByTagName() | HTMLCollection | Yes | Tag only |
querySelector() | Element | No | CSS selector |
querySelectorAll() | NodeList | Yes | CSS selector |
✅ Beginner Level
<li> elements and log how many there are.✅ Challenge Level
querySelectorAll() to select them and change their color to red.Got it — let’s build Module 3: Changing Content in the DOM so it’s easy to teach and practice.
I’ll give lesson notes, code examples, a comparison table, practice exercises, and a ready-to-use teaching script.
src, href, alt, etc.)We can change only the text (without HTML tags) using:
.innerText
<p id="myPara">Hello</p>
<script>
document.getElementById("myPara").innerText = "Hello from JavaScript!";
</script>
.textContent
document.getElementById("myPara").textContent = "Updated text";
Use .innerHTML to replace the inside HTML.
document.getElementById("myPara").innerHTML = "<b>Bold text</b>";
⚠ Note: Be careful with user input (XSS risk).
We can use:
.setAttribute(name, value) → sets an attribute.getAttribute(name) → gets an attribute value
<img id="myImg" src="old.jpg" width="200">
<script>
document.getElementById("myImg").setAttribute("src", "new.jpg");
</script>
For form fields:
document.getElementById("username").value = "John";
| Method | Changes What? | Reads Hidden Text? |
|---|---|---|
.innerText | Text only | No |
.textContent | Text only | Yes |
.innerHTML | HTML structure | N/A |
.setAttribute() | Attributes | N/A |
.value | Input value | N/A |
✅ Beginner
<h1> from “Welcome” to “Hello World”.src of an image.✅ Challenge
<p> with “Click the button to update me”..innerHTML.“In the last module, we learned how to find elements in the DOM. Now we’ll change them. This is how websites update without a refresh — like showing a live score or updating a news headline. We can change only the text, or even replace the whole HTML inside an element. For example,
.innerTextchanges only the visible text, while.innerHTMLlets you insert HTML tags too. And if we want to change things like an image’s source or a link’s address, we use.setAttribute(). Let’s try replacing an image by changing itssrc…”
If you want, I can prepare Modules 1–3 as a single interactive HTML page
where each module has:
That would make your teaching hands-on and fun.
Do you want me to prepare that combined demo?
Alright — let’s make Module 4: Styling Elements clear, visual, and ready for teaching.
I’ll include lesson notes, examples, practice tasks, and a short teaching script so your students can both see and try the changes.
.style.classList.style.property
element.style.propertyName = "value";
⚠ Property names use camelCase in JavaScript (e.g., backgroundColor not background-color).
Example:
<div id="box" style="width:100px; height:100px; background:gray;"></div>
<script>
document.getElementById("box").style.backgroundColor = "red";
document.getElementById("box").style.borderRadius = "10px";
</script>
.classListExample:
<style>
.highlight { background-color: yellow; }
.big { font-size: 24px; }
</style>
<p id="text">Hello</p>
<script>
let p = document.getElementById("text");
p.classList.add("highlight");
p.classList.add("big");
</script>
Common .classList methods:
.add("className").remove("className").toggle("className") → Adds if missing, removes if present.contains("className") → Returns true/falseWe can set multiple styles by:
Object.assign(element.style, {
backgroundColor: "blue",
color: "white",
padding: "10px"
});
✅ Beginner
<div> background color to green using .style.<h1> font size using .style.fontSize.✅ Challenge
<body> (changes background and text color).“In Module 3, we changed content. Now, let’s change how it looks. JavaScript can style elements in two ways — directly, using
.style.property, or by adding/removing CSS classes with.classList. Changing styles directly is quick, but adding classes is cleaner because you keep design in CSS and just tell JavaScript when to apply it. Let’s try both methods — first, let’s make a box turn red, then let’s toggle a dark mode for the whole page.”
If you want, I can make Modules 1–4 in one HTML page with buttons so you can demonstrate each step interactively.
It will be perfect for teaching because your students can click and instantly see the effect.
Do you want me to prepare that interactive combined HTML file next?
Alright — here’s Module 6: Forms and Input explained step-by-step, with teaching notes, examples, practice exercises, and a ready-to-use teaching script.
📌 Think of forms as the “conversation” between your website and the user.
We can use .value to get or set input field values.
Example:
<input type="text" id="username" placeholder="Enter your name">
<script>
let nameField = document.getElementById("username");
console.log(nameField.value); // Empty at first
</script>
<input type="text" id="name" placeholder="Type something">
<p id="output"></p>
<script>
document.getElementById("name").addEventListener("input", function(){
document.getElementById("output").innerText = "You typed: " + this.value;
});
</script>
event.preventDefault() to stop this.
<form id="myForm">
<input type="text" id="user" placeholder="Your name">
<button type="submit">Submit</button>
</form>
<script>
document.getElementById("myForm").addEventListener("submit", function(e){
e.preventDefault(); // stop reload
let name = document.getElementById("user").value;
alert("Hello, " + name);
});
</script>
<input type="checkbox" id="subscribe"> Subscribe
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female
// Checkbox
document.getElementById("subscribe").checked; // true/false
// Radio buttons
let gender = document.querySelector('input[name="gender"]:checked').value;
✅ Beginner
✅ Challenge
“We’ve learned how to react to clicks and keypresses, but forms are where users actually give us data. JavaScript can read these values, check them, and even stop the form from sending until the data is correct. The key here is
.valuefor text inputs and.checkedfor checkboxes. Also, remember to usepreventDefault()if you want to stop the form from reloading. Let’s try making a form that says hello to the user after they submit their name.”
If you want, I can make Modules 1–6 in one HTML teaching file where each module has:
That way, you can just open it in the browser and teach straight from there without switching files.
Do you want me to prepare that full Modules 1–6 combined HTML demo?
Alright — here’s Module 7: DOM Traversal in a way that’s beginner-friendly but still thorough enough for advanced understanding.
I’ll include lesson notes, code examples, practice tasks, and a teaching script so it’s ready to teach.
📌 This is useful when you know the position of an element relative to another, but not its exact ID/class.
let parent = document.getElementById("container");
console.log(parent.children); // HTMLCollection of child elements
console.log(parent.firstElementChild); // First child element
console.log(parent.lastElementChild); // Last child element
Example:
<div id="container">
<p>First</p>
<p>Second</p>
<p>Third</p>
</div>
<script>
let box = document.getElementById("container");
box.firstElementChild.style.color = "red"; // Colors "First"
</script>
let child = document.querySelector("#container p");
console.log(child.parentElement); // The <div> with id="container"
let first = document.querySelector("#container p");
console.log(first.nextElementSibling); // "Second" paragraph
console.log(first.nextElementSibling.textContent);
console.log(first.previousElementSibling); // null (no previous sibling)
.childNodes includes text nodes (like spaces, line breaks)..children only includes element nodes.
<ul id="list">
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
<script>
let list = document.getElementById("list");
let banana = list.children[1];
banana.style.color = "blue"; // Colors "Banana"
banana.previousElementSibling.style.color = "red"; // "Apple"
banana.nextElementSibling.style.color = "green"; // "Cherry"
</script>
✅ Beginner
<div> and change its text.<ul> and change its background.✅ Challenge
<ul>, find the second item using .firstElementChild.nextElementSibling and make it bold.“Up to now, we’ve been grabbing elements directly with
getElementByIdorquerySelector. But sometimes we don’t know the exact selector — instead, we know where an element is relative to another one. DOM traversal lets us move up, down, or sideways in the DOM tree. We can grab parents, children, and siblings easily. This is especially useful when handling events — for example, when you click a button inside a card, you can find the card’s title by moving up to its parent, then down to the right child.”
If you want, I can make Modules 1–7 into a single interactive HTML demo where each module has a “Run Example” button and live results — so your students can try every traversal method right there in the browser.
Do you want me to prepare that combined teaching file?
Got it — here’s Module 8: Creating & Removing Elements in a clear, step-by-step teaching format with examples, practice, and a ready-to-use teaching script.
let newDiv = document.createElement("div");
newDiv.textContent = "Hello, I’m new here!";
or:
newDiv.innerHTML = "<strong>Hello</strong> World!";
document.body.appendChild(newDiv);
Full Example:
<div id="container"></div>
<script>
let newP = document.createElement("p");
newP.textContent = "This is a new paragraph.";
document.getElementById("container").appendChild(newP);
</script>
Two main ways:
let element = document.getElementById("removeMe");
element.remove();
let parent = document.getElementById("container");
let child = document.getElementById("item1");
parent.removeChild(child);
let newItem = document.createElement("li");
newItem.textContent = "Mango";
let list = document.getElementById("fruits");
list.insertBefore(newItem, list.children[1]); // before Banana
<div id="box"></div>
<button id="add">Add Paragraph</button>
<button id="remove">Remove Last Paragraph</button>
<script>
let box = document.getElementById("box");
document.getElementById("add").addEventListener("click", function(){
let p = document.createElement("p");
p.textContent = "New paragraph";
box.appendChild(p);
});
document.getElementById("remove").addEventListener("click", function(){
if (box.lastElementChild) {
box.removeChild(box.lastElementChild);
}
});
</script>
✅ Beginner
<ul> and add a new <li> with text “New Item”.<ul>.✅ Challenge
<li> each time it’s clicked.<li> items.“So far, we’ve worked with elements that already exist. But what if you want new content — say, a new chat message or a notification? We can create elements with
document.createElement(), set their content with.textContentor.innerHTML, and then place them into the DOM using.appendChild()or.insertBefore(). Removing is just as simple — use.remove()for a single element or.removeChild()if you’re working from the parent. Let’s make a button that adds new paragraphs and another that deletes them.”
If you want, I can now prepare Modules 1–8 in one interactive HTML teaching file, with a tab or section for each module and live editable examples so students can try code instantly in the browser.
That would make your course fully hands-on from start to finish.
Do you want me to make that combined interactive file?
The SUM function adds multiple numbers or ranges quickly to calculate the total.
Syntax:
=SUM(number1, number2, ...)
or
=SUM(range)
| Product | Price | Quantity | Total |
|---|---|---|---|
| Pen | 10 | 5 | 50 |
| Notebook | 25 | 2 | 50 |
| Pencil | 5 | 10 | 50 |
| Total | =SUM(D2:D4) → 150 |
D2:D4).=SUM(D2:D4) in the total cell.The AVERAGE function calculates the mean (average) of numbers or ranges.
Syntax:
=AVERAGE(number1, number2, ...)
or
=AVERAGE(range)
| Student | Marks |
|---|---|
| John | 80 |
| Mary | 75 |
| Alex | 90 |
| Average | =AVERAGE(B2:B4) → 81.67 |
B2:B4).=AVERAGE(B2:B4) to calculate average.The ROUND function rounds a number to a specified number of digits.
Syntax:
=ROUND(number, num_digits)
| Value | Formula | Result |
|---|---|---|
| 123.456 | =ROUND(A2, 2) | 123.46 |
| 78.9876 | =ROUND(A3, 1) | 79.0 |
=ROUND(A2, 2) to round to 2 decimal places.ROUNDUP always rounds a number up; ROUNDDOWN always rounds down.
Syntax:
=ROUNDUP(number, num_digits)
=ROUNDDOWN(number, num_digits)
| Value | Formula | Result |
|---|---|---|
| 4.2 | =ROUNDUP(A2, 0) | 5 |
| 4.8 | =ROUNDDOWN(A3, 0) | 4 |
=ROUNDUP(A2, 0) to round up.=ROUNDDOWN(A3, 0) to round down.num_digits as needed.The PRODUCT function multiplies numbers or ranges.
Syntax:
=PRODUCT(number1, number2, ...)
or
=PRODUCT(range)
| Item | Price | Qty | Total |
|---|---|---|---|
| Bag | 500 | 2 | =PRODUCT(B2, C2) → 1000 |
| Shoes | 800 | 1 | =PRODUCT(B3, C3) → 800 |
=PRODUCT(B2, C2) to multiply price × quantity.The QUOTIENT function returns the integer part of a division (ignores remainder).
Syntax:
=QUOTIENT(numerator, denominator)
| Days | Formula | Result (Weeks) |
|---|---|---|
| 10 | =QUOTIENT(A2, 7) | 1 |
| 21 | =QUOTIENT(A3, 7) | 3 |
=QUOTIENT(10,7) to get full weeks from days.The MOD function returns the remainder after division.
Syntax:
=MOD(number, divisor)
| Total Items | Box Size | Formula | Remainder |
|---|---|---|---|
| 10 | 3 | =MOD(A2, B2) | 1 |
| 25 | 4 | =MOD(A3, B3) | 1 |
=MOD(10,3) to get remainder.The POWER function raises a number to a specified exponent.
Syntax:
=POWER(number, power)
| Number | Power | Formula | Result |
|---|---|---|---|
| 5 | 2 | =POWER(A2, B2) | 25 |
| 3 | 4 | =POWER(A3, B3) | 81 |
=POWER(5, 2) to calculate 5 squared.The SQRT function returns the square root of a number.
Syntax:
=SQRT(number)
| Number | Formula | Result |
|---|---|---|
| 144 | =SQRT(A2) | 12 |
| 81 | =SQRT(A3) | 9 |
=SQRT(144) to find the square root.The ABS function returns the absolute value of a number, removing any negative sign.
Syntax:
ABS(number)
| Value | Formula | Result |
|---|---|---|
| -50 | =ABS(A2) | 50 |
| 75 | =ABS(A3) | 75 |
=ABS(-50) to get positive 50.