DOM Scripting Tutorial

By Xah Lee. Date: . Last updated: .

This is a beginner-friendly, example based, practical tutorial for writing web applications with JavaScript.

This tutorial teaches you the core standard web technology. No library, no framework, no JQuery, are used in this tutorial.

Basic Examples

  1. Change CSS
  2. Change Node Content
  3. Create/Insert Node
  4. Remove Node
  5. Get Elements by ID, Tag, Name, Class, CSS Selector
  6. Get Element's Attribute Value
  7. Set Element's Attribute Value
  8. List/Add/Remove Class Attribute
  9. Add/Remove Event Handler

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. Node Type, Name, Value
  3. Navigate DOM Tree


  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