30 DOM Practice Questions

🟢 Beginner Level (1–10)

  1. Select an element with id "title" and print it in console.
  2. Change the text of a paragraph using innerHTML.
  3. Change background color of a div to blue.
  4. Select all elements with class "box" and print their length.
  5. Change text of a button when it is clicked.
  6. Add a new <li> item inside a <ul>.
  7. Remove an element from the page using JavaScript.
  8. Change an image src on button click.
  9. Show an alert when user clicks a button.
  10. Change font size of a heading using JavaScript.

🟡 Intermediate Level (11–20)

  1. Toggle a class "dark-mode" on body when button is clicked.
  2. Count number of <p> tags in a page.
  3. Loop through multiple elements and change their color.
  4. Create a button that hides and shows a div.
  5. Get value from input field and display it in a div.
  6. Change placeholder text of an input field.
  7. Validate if input field is empty on button click.
  8. Add multiple list items dynamically using array.
  9. Create a counter (increase/decrease value on button click).
  10. Detect mouse hover and change element color.

🔵 Advanced Level (21–30)

  1. Create a live character counter for a textarea.
  2. Build a simple image slider (next/previous buttons).
  3. Validate email format using JavaScript.
  4. Highlight selected menu item when clicked.
  5. Create a dropdown menu that opens on click.
  6. Build a tab system (click → show content).
  7. Create a to-do list (add + delete tasks).
  8. Detect keyboard input and show pressed key.
  9. Prevent form submission if validation fails.
  10. Create a real-time search filter (filter list items as user types).

🔥 Bonus Challenge (Real-world)

👉 Build a mini app combining multiple DOM concepts:

  • Dark mode toggle
  • Form validation
  • To-do list
  • Counter

💡 Tip (Very Important)

👉 First 10 → Basics
👉 Next 10 → Logic building
👉 Last 10 → Real-world projects