- Select elements through Class
- Select an element through Attribute
"Input [name = 'first _ name']"); |
- Select elements using the composite CSS Selector
"# Contents ul. people li "); |
$ ("A. external: first ");$ ("Tr: odd ");// Select # All input elements in myForm$ ("# MyForm: input ");$ ("Div: visible ");// Except the first three divs$ ("Div: gt (2 )");// All the divs that are currently animated.$ ("Div: animated "); |
// Search for all the <a> elements whose rel attributes end with "thinger"$ ("A [rel $ = 'thinger ']"); |
.
- Determines whether the selector contains any element.
// This cannot be runIf ($ ("div. foo ")){...} |
// Test whether the selector contains elements.If ($ ("div. foo"). length ){...} |
- Refining and filtering Selector
// Refining Selector$ ("Div. foo"). has ("p"); // <p> tag contained in the div. foo Element$ ("H1"). not (". bar"); // No h1 element whose class is bar$ ("Ul li"). filter (". current"); // The class is the unordered list subitem of current.$ ("Ul li"). first (); // subitem of the first unordered list$ ("Ul li"). eq (5); // The sixth subitem. |
"Form input [name = 'gender']: radio "); |
Alternatively, you can use other optional methods that are better than adding a pseudo selector to a tag name or some other selector.