From return new jQuery. fn. init (selector, context, rootjQuery), we can see that
The selector and context parameters are transmitted when we call the jQuery method.
So what are the possibilities of selector and context.
For ~ The nine rows may be analyzed in detail.
If selector is a string, the first check is the html code or # id.
The if Statement of Row 3 starts with "<", ends with ">", and the length is greater than or equal to 3. assume that this is an HTML clip. Here we only assume that it is not necessarily the html code of Hefei. for example, "<div> <guofsfsdfd> ";
Else In line 1: indicates that the Code is not html. In this case, use a regular expression to detect the code.
I am not familiar with regular expressions, but I can understand them roughly. The matching result is html and id. The matching result is assigned to match.
After analyzing the selector and context parameters, do we forget the rootjQuery parameter.
This parameter is defined internally by jQuery, not manually passed in from the outside.
We can probably guess the approximate situation of this parameter from the name: the root jQuery object.
See the source code definition:
Under what circumstances will the program use this parameter?
1. When search for document. getElementById () fails,
2. selector is a function:
3. selector is a selector expression and context is not specified;