jQuery was created in 2006 by John Resig to address browser incompatibilities and simplify HTML DOM manipulation, event handling, animations, and AJAX.
For over 10 years, jQuery has been the most popular JavaScript library globally. However, since the release of JavaScript Version 5 (2009), many of the utilities provided by jQuery can now be achieved with just a few lines of standard JavaScript.
Retrieve the element with the id “id01”.
myElement = $(“#id01”); |
myElement = document.getElementById(“id01”); |
Retrieve all <p>
elements.
myElements = $(“p”); |
myElements = document.getElementsByTagName(“p”); |
Retrieve all elements with the class “intro”.
myElements = $(“.intro”); |
myElements = document.getElementsByClassName(“intro”); |
Retrieve a list of all <p>
elements with the class “intro”.
myElements = $(“p.intro”); |
myElements = document.querySelectorAll(“p.intro”); |