This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

  • 19.1 jQuery Selectors

    • jQuery was created in 2006 by John Resig. It was designed to handle Browser Incompatibilities and to simplify HTML DOM Manipulation, Event Handling, Animations, and Ajax.
    • For more than 10 years, jQuery has been the most popular JavaScript library in the world.
    • However, after JavaScript Version 5 (2009), most of the jQuery utilities can be solved with a few lines of standard JavaScript:

    Finding HTML Element by Id

    Return the element with id="id01":

    jQuery

    var myElement = $("#id01");

    Try it yourself

    JavaScript

    var myElement = document.getElementById("id01");

    Try it yourself

    Finding HTML Elements by Tag Name

    Return all <p> elements:

    jQuery

    var myElements = $("p");

    Try it yourself

    JavaScript

    var myElements = document.getElementsByTagName("p");

    Try it yourself

    Finding HTML Elements by Class Name

    Return all elements with class="intro".

    jQuery

    var myElements = $(".intro");

    Try it yourself

    JavaScript

    var myElements = document.getElementsByClassName("intro");

    Try it yourself

    Finding HTML Elements by CSS Selectors

    Return a list of all <p> elements with class="intro".

    jQuery

    var myElements = $("p.intro");

    Try it yourself

    JavaScript

    var myElements = document.querySelectorAll("p.intro");

    Try it yourself

    Navigate this module

    Eventually the navigation links, above, will be replaced by these << (previous) and >> (next) buttons below.



    JavaScript icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon