Mastering jQuery vs Modern JavaScript helps you write clean and reliable jQuery code. Follow standard conventions, test edge cases, and keep logic simple. Try running the code example below and complete the exercises to build confidence.
jQuery vs Modern JavaScript Code Example
jQuery
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<p id="a">jQuery</p>
<p id="b">Vanilla JS</p>
<script>
// jQuery
$("#a").css("color", "#0769AD").on("click", () => alert("jQuery click"));
// Same thing in modern JavaScript
const b = document.querySelector("#b");
b.style.color = "#EAB308";
b.addEventListener("click", () => alert("Vanilla click"));
</script>
Free sign-in required · Google login available
jQuery vs Modern JavaScript Practice Exercises
Check what you learned in “jQuery vs Modern JavaScript”.
/ 3 solved
Fill in the blank
The vanilla equivalent of $("#id").
document.("#id")
✓ Correct!Not quite. Try again.
Multiple choice
What is the vanilla equivalent of $.getJSON(url)?
✓ Correct!Not quite. Try again.
Code challenge
Without jQuery, set the text of #out to "Vanilla!" using document.querySelector.
Write the code in the live editor. Your answer is checked automatically.