This refers to a javascript Object and $ (this) is a jquery object. If you do not know this, you can read this article.
The Code is as follows:
JQuery. prototype. test = function (){
This.css ("color", "#99"); // here this is a jquery object, not a dom object.
Alert (this [0]); // here this [0] refers to the dom Node object
}
The Code is as follows:
$ ("Body"). click (function (){
$ (This). test ();
Certificate (this).test().html (this. nodeName). hide (10000 );
})
When the click method is used on the page, it is equivalent to creating a new Jquery object and then calling its click method. The parameters in the method are a javascript function, this indicates a javascript Object. this is the syntax keyword of javascript itself. It points to a javascript Object. Therefore, you can use the method of the target javascript Object.
JQuery. prototype. test is equivalent to creating a test method for the query object. Therefore, this should be the jquery object.
This [0] can be used to convert a jquery object to a dom Node object.
Because this always points to the object that calls this method (function) (except the call and apply methods)