3 ms·
Vanilla JS is quite nice these days, the only advantages jQuery has now is the fact that it's somewhat less verbose for DOM things and has support for old brows
by easrng 5y ago
Vanilla JS is quite nice these days, the only advantages jQuery has now is the fact that it's somewhat less verbose for DOM things and has support for old browsers.
// For example, instead of
$("#somebutton").click(() => alert("Hello"))
// You would do
document.querySelector("#somebutton").addEventListener("click", () => alert("Hello"));
// Instead of
$("#message").text("Important Message")
// You would do
document.querySelector("#message").textContent = "Important Message";
// Instead of
$("#things .thing").css("color", "red")
// You would do
for(let e of document.querySelectorAll("#things .thing")) e.style.color = "red";
// Instead of
await $.ajax("https://httpbin.org/get").then((_1, _2, {responseJSON}) => responseJSON)
// You would do
await fetch("https://httpbin.org/get").then(e => e.json())