Understand jQuery selector and Sizzle, and jquery selector sizzle
What is a jQuery selector?
JQuery selector is generally a tool for getting html elements. For example, $ ("p") selects <p> elements. $ ("p") is the method of jQuery selector, so that you can obtain (select) <p> element in html.
JQuery selectors include element selectors, attribute selectors, and CSS selectors. (I personally think this category is a little nonsense)
Note: The attribute selector does not mean selecting an attribute, but selects an element based on the attribute.
Http://www.w3school.com.cn/jquery/jquery_selectors.asp
What is an html element? What is an attribute?
The start tag + content + end tag in the html code constitutes an element. The English element is used.
<P> This is a tag, </p> it is also a tag, and English is a tag.
<P> XXX </p> is an element.
Special <br/> This is also a tag.
The attribute is clearly known. For example, bgcolor = "red" is the attribute in the tag <body bgcolor = "red">.
That is to say, attributes are in tags. in the case of no confusion, we often call elements as tags (Some people include me often), which is not a big problem.
How does one implement this function without the jQuery selector?
If jQeury is not used, the native js method of Simple Element selectors is getElementById (), getElementByClassName () and other functions to obtain elements. In this case, $ only simplifies the code writing method.
Of course, this is just the simplest case. $ Is used to call getElementById () in this case, but the complex situation is implemented through the complex jQuery selector.
How is the jQuery selector implemented?
In w3c, jQuery uses the CSS selector to select HTML elements. I personally once again feel more nonsense. Therefore, we recommend that you read w3c and other things about the principle.
You can refer to this article:
Introduction to jQuery selector engine and Sizzle: http://blog.csdn.net/freshlover/article/details/10813657
Sizzle engine-Principle and Practice (I): http://www.cnblogs.com/xesam/archive/2012/02/15/2352466.html
What is sizzle?
Sizzle is A pure js CSS selector engine (A pure-JavaScript CSS selector engine ). The latest version is 2.1.1(jquery-sizzle-2.1.1-jquery.2.1.2-11-gf8ef711.zip ).
Official website is: http://sizzlejs.com/
It is part of the official jQuery website. (There are five parts on the jQuery Official Website: jQuery, jQueryUI, jQueryMobile, Sizzle, and QUnit), but it is independent. Although jQuery uses sizzle, however, you can use sizzle without using jQuery.
Source: http://blog.csdn.net/ouyida3/article/details/43915543
2015.2.23