- What is the DOM, and how does the browser create it?
- Difference between
getElementById
,getElementsByClassName
,querySelector
, andquerySelectorAll
. - Difference between
innerText
,textContent
, andinnerHTML
. - What are event listeners? Why use
addEventListener
instead of inline handlers likeonclick
? - Explain
==
vs===
with examples. - What is event bubbling? What is event capturing? How can you stop propagation?
- Explain event delegation and why it’s useful.
- What is the difference between
target
andcurrentTarget
in event objects? - How do you dynamically create and append elements in the DOM?
- What is the difference between
removeChild
andremove()
?
Code Questions
- Swap Text Between Two Elements
-
Write code to swap the text of two
<div>
elements usinggetElementById
.- Live Character Counter
-
Implement a live character counter for a text area. When typing, update a
<span>
showing the remaining characters (max 100).- Color Changer
-
Create three buttons: Red, Green, Blue. Clicking each should change the page’s background color using
querySelector
.- Stop Event Propagation
-
Create nested elements (parent and child divs). Add click listeners to both. Use
stopPropagation()
to prevent bubbling.- Dynamic List Builder
Build an unordered list where clicking a button adds a new list item dynamically.
🛠 Mini Project: Interactive To-Do List with Event Delegation
Features:
- Add tasks dynamically.
- Mark tasks as complete on click.
- Delete tasks using event delegation.
- Style completed tasks with a strike-through.
Top comments (0)