Recommended learning resources from: Zhang Ziqiu http://www.cnblogs.com/zhangziqiu/tag/jQuery%e6%95%99%e7%a8%8b/
Summary:
In the previous example, we have the ID selector $ ("# btnshow") to capture controls on the page. This article describes how to use selector to capture elements and objects. $ Is short for jquery.
Content:
The jquery selector is used to capture objects on the page and return them in the form of a jquery package set.
Note the differences between DOM objects and wrapper sets:
Vardiv = Document. getelementbyid ("testdiv ");
Vardivs = Document. getelementbytagname ("Div"); these are DOM objects
Vardivs = $ (divs );
Vardiv = $ ("# testdiv"); // jquery package set, either a or a group
Vard = $ ("# Div") [0]; get the first one in the set. In this case, the returned Dom is not the jquery package set.
$ ("# Div"). Each (function () {alert (this)}); The Traversal method included in jquery. For example, each will pass the traversal Function
Use of the jquery selector:
1. Basic Selector
$ ("# Divid"): select the element whose ID is divid.
$ ("A"): select all <A> Elements
$ (". Bgred"): select all elements whose CSS class is bgred.
$ ("*"): Select all elements
$ ("# Divid, A,. bgred"): the matching contents of these selectors are selected at the same time.
2. Hierarchical Selector
3. Basic filter Selector
$ ("# Div: First"): matches and finds the first element with the ID Div.
$ ("TR: Last"): Find the last row of the table
......
4. Content Filter
$ ("Div: Has (p)"). addclass ("test"): adds a test class to all DIV elements containing the P element.
...
5. Visibility Filtering
6. Attribute Filtering
7. subelement Filtering
8. Select a form
9. Form Filtering