jQuery Basic object access

CSS selector types

  • Universal selector: *
  • Id selector: #element
  • Class selector: .element
  • Tag selector: element

jQuery object access HTML elements using same symbol as CSS selector :

$("*") : all elements

$("#element") : equivalent to document.getElementById("element");

$(".abc") : all elements with class abc

$("div") : all <div> elements in the HTML

Two levels of object access

$("#a, .b, p") : represents an element that has an id="a" and an element with class b and all the p elements.

$("#a .b p") : indicates that all the p elements in the element with class="b" in the element with id="a"

Copyright 2014-2017 by DeveloperTut.com. All Rights Reserved.