The problem
By the mid-2000s pages did more and more in JavaScript, but every browser had its own quirks. Internet Explorer before version 9 had attachEvent instead of addEventListener, finding elements by CSS selector was not built in (querySelectorAll only reached browsers in 2008–2009), and a fade or a request to the server took dozens of lines full of browser checks.
The idea
$(selector) returns a set of elements that you change with chained methods: $("#todo-list li").not(".done").length. jQuery hides the differences between browsers in events, DOM traversal, effects and AJAX.
The page arrives from the server as finished HTML and jQuery adds behaviour to it. The DOM itself holds the state: a todo is done when its <li> has the class done.
What hurt next
When the data lives only in the DOM, every feature reads and writes the page directly: the counter counts <li> elements, the filter checks classes. As apps grew, handlers changing the page from many places became hard to follow ("jQuery spaghetti"), and there was no model of the data to test, save or reuse. Libraries like Backbone moved the data into models and kept the page in views.
How close this is to the original
Runs jQuery 4.0.0 (January 2026). Code from 2006–2012 often used $.trim(), .bind() or .live(): .live() was removed in jQuery 1.9 and $.trim() in 4.0, so the demo uses String.prototype.trim() and .on() (jQuery 1.7).