๐Ÿ’› JavaScript

jQuery to Vanilla JS โ€” The Translation Table

๐Ÿ“… Jul 5, 2026 โฑ 3 min read

College materials and older codebases still speak jQuery; interviews expect vanilla. The full translation:

The table

// SELECT
$(".card")               โ†’ document.querySelectorAll(".card")
$("#app")                โ†’ document.querySelector("#app")

// EVENTS
$(btn).on("click", fn)   โ†’ btn.addEventListener("click", fn)
$(document).ready(fn)    โ†’ defer attribute, or DOMContentLoaded
$(list).on("click", "li", fn) โ†’ delegation with e.target.closest("li")

// CLASSES & CONTENT
$(el).addClass("on")     โ†’ el.classList.add("on")
$(el).toggleClass("on")  โ†’ el.classList.toggle("on")
$(el).text("hi")         โ†’ el.textContent = "hi"
$(el).attr("href")       โ†’ el.getAttribute("href")
$(el).hide()             โ†’ el.hidden = true

// DOM
$(parent).append(el)     โ†’ parent.append(el)
$(el).remove()           โ†’ el.remove()
$("<li>")                โ†’ document.createElement("li")

// AJAX
$.getJSON(url, cb)       โ†’ const data = await (await fetch(url)).json()

// ANIMATION
$(el).fadeIn(300)        โ†’ CSS transition + el.classList.add("visible")

Why jQuery faded

It papered over 2010's browser inconsistencies โ€” querySelector, fetch and classList didn't exist. The platform absorbed its best ideas ($ becoming querySelector is almost literal). It's not "bad", just redundant โ€” and 30KB of redundant.

Reading legacy jQuery remains a real workplace skill; writing new code in it is the thing to avoid. Full modern DOM: DOM lessons.

โ† All Articles