Already do not know is the first several times determined to read jquery, nor is the first few times just see to give up, I think that only a continuous record is my driving force, do not want to always only see a beginning.
Continuously updated ING, seeking advice, interpretation, seeking science, writing is fur, seeking advice
In fact, jquery official published a lot of practical API, but there are a lot of methods are not released (of course, not put out the estimate is because the practicality is not strong or a lot of is the basic method, is called), these methods also have some looks good oh, hand the cheap side to write out, prevent later forget;
Of course, if there is the API of Chinese documents, my English API is really lazy to look at, hehe must be some new methods of wood to see the smecta, if there is already written in the API has told me, must kill it, I hope I can insist on the jquery read and continue to update it.
First declare the scene, I look at the jquery.1.8.2 jquery source code, but the thing is very rubbing is to help the document with 1.4.1.
1.$.fn.toarray ()
Cut the given piece of data and return it, it's a pity that jquery here is simply an array to return (estimated to be of no great use), without cutting capability
Here's how:
$.fn = {
Toarray:function () {
Return Core_slice.call (this);
}
}
If you want it to be able to cut the data to change it (this is not like a jquery get so human, specifically how to deal with JS native Slice how to deal with it how to deal with it)
Toarray:function (start, end) {
Return Core_slice.call (this, start, end);
}
2.$.fn.pushstack
This guy looked like he thought it was a stack, and it looked like it was a combination of a new set of elements (I'll say it first) I regret it, and when I see the map I know that only the first parameter is really just an array of operations) _ (---- The simplest way to make a stack is to use a one-dimensional array, which I don't understand.
The code is as follows:
Pushstack:function (elems, name, selector) {
Build a new jQuery matched element set
var ret = Jquery.merge (This.constructor (), elems);
ADD the old object onto the stack (as a reference)
Ret.prevobject = this;
Ret.context = This.context;
if (name = = = "Find") {
Ret.selector = This.selector + (this.selector? "": "") + selector;
} else if (name) {
Ret.selector = This.selector + "." + Name + "(" + selector + ")";
}
Return the newly-formed element set
return ret;
}
I just looked at it when the Tiger live, do not know what it is, and then I looked at the superficial, my understanding: Simple understanding is a new string splicing, if you take a serious look at the jquery not, closest, find and other such a method called in a set will find its role
For example: $ (' div '). Not (' span ') = $ (' Div.not (span) ') He did not want what I had expected before, $ (' div ') into an array, and then to remove the data instead of taking the span corresponding data directly in the process of the search (I think so) .
3.$.fn.end ()
Actually, he is. $ (document) is a jquery object ^_^
4.$.fn.push, Sort, splice
What is the meaning of these functions, all directly called JS native implementation.
5.$.holdready
Although the definition of this thing, actually I did not see the call there, looked at a note appears to control the state of $.ready.
6.$.isfunction (obj)
Determine if an object is a function actually, I think it's the class2type guy in the house. It's a big part of it.
- [Object Array] : "Array"
- [Object Boolean] : "boolean"
- [Object Date] : "date"
- [Object Function] : "function"
[Object number] : "number"
[Object Object] : "Object"
- [Object REGEXP] : "regexp"
- [Object String] : "string"
7.$.isnumeric (obj)
Determines whether the object is a number, whether the IsArray is an array, whether the IsWindow is the window object itself or contains the Window object, which can be seen in the IFRAME
8.$.isplainobject
This guy is checking to see if an object is a normal object (not a Window object, not a DOM, not a constructor and a isprototypeof, it's a withered object.
9.isEmptyObject (obj)
Checks whether an object is an empty object
10.$.error (msg)
Output an error to the browser console---486
11.parseHTML
Converts a string into a sequence of HTML. If the string of the tag returns a JS DOM, it also supports whether the script tag and execution ability are filtered in the string. Looking at it, jquery uses it to transform the string containing the tag that JS dynamically inserts into a jquery dom when initializing (init) page, and then use it to do the action;
For example: $ (' < span >aa\ '). AppendTo (' body '); Turn this string into a DOM and insert the body tag (this method can count as meaningless because $ (' HTML string ') is more practical)
12.$.parsejson (data)
Convert a string into a JSON object, with it in IE6, 7 can not introduce json2.js, test is like this
13.$.parsexml (Data)
Converts a string of XML into a JS object
14.$.globaleval (data)
A string to do JS execution
15.$.camelcase (data)
To convert a string to a Cheng naming method
16.$.nodename (elem, Name)
Determine if a JS Dom is the name of a tag (the first one can only be a single DOM, not the array)
17.$.makearray (arr, ret)
Merge two objects, if both are arrays then arr merges into RET,//results is for internal usage only
$inArray (Elem, arr, startpos)
Search element at the beginning of the array from the specified position,-1 not found
19.$.merge (First,second)
Merging two arrays
20.$.grep (Elems, callback, INV)
Filter the condition element $.grep from the collection ([1,2,3,4],function (i) {return i%3;})
21.$.proxy (FN, context)
is mainly to let the context integrated FN in one of the hair, the main principle is to use the Apply
Who writes an example: var obj = {a:function () {alert (1)},b:function () {alert (2)}};
$.proxy (obj, ' B ') (); Execute it and know. In fact, it is obj.b ()
In fact, the internal core code is
Fn.apply (Context, Args.concat (Core_slice.call (arguments)));
$.now.
As the name implies to get the current timestamp the function content is very simple return (new Date ()). GetTime ();
Those functions not mentioned in the jquery API documentation