DOM Scripting Tutorial

By Xah Lee. Date: . Last updated: .

This is a beginner-friendly tutorial for writing web applications with JavaScript.

This tutorial is example based. And, teaches you the core standard web technology. No libray, no framework, no JQuery, are used in this tutorial.

Basic Examples

  1. Change CSS
  2. Change Node Content
  3. Insert Node
  4. Remove Node

Web Scripting Overview

  1. Browser Window Object
  2. Event Basics
  3. JS Load Order
  4. What Does Live Object Mean?
  5. Array vs NodeList vs HTMLCollection
  6. DOM Whitespace Nodes

Basic DOM Methods

  1. Basic DOM Methods
  2. Get Elements by ID, Tag, Name, Class, CSS Selector
  3. Get Element's Attribute Value
  4. Set Element's Attribute Value
  5. List/Add/Remove Class Attribute
  6. Node Type, Name, Value
  7. Navigate DOM Tree
  8. Add / Remove Event Handler


  1. HTML Form
  2. Visit URL in a New Window
  3. Instant Field Validation
  4. Input Field Validation
  5. HTML Input Range: Slider UI

How To

  1. Encode URL, Escape String
  2. Browser Info, Navigator Object
  3. Get URL (window.location)
  4. Web Cookies
  5. Web Storage
  6. Find Window Width
  7. WebSocket

Simple Examples

  1. document.write
  2. Image Rollover
  3. Pop-up New Window
  4. Digital Clock
  5. Stopwatch
  6. Fading Box
  7. Fading Box with CSS Transition
  8. Shake Box
  9. Tooltip
  10. Falling Hearts
  11. Scroll Following Box


  1. jQuery Basics
  2. jQuery() vs querySelectorAll()
  3. JS: How to Write a JQuery Plugin


Misc Tips

  1. Value of “this” in Event Handler
  2. Event Delegation
  3. Get Current Script Tag
  4. insertAfter Element
  5. Randomize List
  6. create Document Fragment
  7. innerHTML, nodeValue, textContent, innerText?
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

Ask me question on patreon