In the previous section, the jQuery selector shows examples of how to select HTML elements. The key point is to learn how the jQuery selector accurately selects the elements you want to apply. The jQuery element selector and attribute selector allow you to select HTML elements by Tag Name, attribute name, or content. The selector allows you to operate on HTML element groups or individual elements. In html dom terminology, selector allows you to operate a DOM element group or a single DOM node. JQuery element selector jQuery uses the CSS selector to select HTML elements. $ ("P") Select the <p> element. $ ("P. intro") select all <p> elements of class = "intro. $ ("P # demo") select all <p> elements of id = "demo. JQuery attribute selector jQuery uses an XPath expression to select an element with a given attribute. $ ("[Href]") selects all elements with the href attribute. $ ("[Href = '#']") select all elements with an href value equal. $ ("[Href! = '#'] ") Select all elements with an href value not equal. $ ("Your href00000000'.jpg ']") select all elements whose href values end with ". jpg. The jQuery CSS selector can be used to change the CSS attributes of HTML elements. The following example changes the background color of all p elements to red: instance $ ("p" ).css ("background-color", "red ") the jQuery selector instance Selects all elements of * $ ("*") # id $ ("# lastname") id = "lastname. class $ (". intro ") all elements of class =" intro "$ (" p ") All <p> elements. class. class $ (". intro. demo ") All class =" intro "and class =" demo "elements: first $ (" p: first ") the first <p> element: last $ (" p: last ") last <p> element: even $ (" tr: even ") All even <tr> element: odd $ (" tr: odd ") all odd <tr> elements: eq (index) $ ("ul li: e Q (3) ") The fourth element in the list (index starts from 0): gt (no) $ (" ul li: gt (3 )") list elements with an index greater than 3: lt (no) $ ("ul li: lt (3)") list elements with an index less than 3: not (selector) $ ("input: not (: empty) ") All input elements not empty: header $ (": header ") All title elements