Explain popular. Links – slippery topic. I never opened to me completely.
What is the difference:
this - element DOM
$ (this) - JQuery object
Answer 1, Authority 100%
In JS there are objects, all sorts of different. The $ ()
function returns the jQuery object, it’s just a JS object with some kind of methods and properties (specified in the jQuery library), and the dom object is another object, it has other properties and methods. Simplified jQuery object is similar to the DOM object roughly as a on B in this example:
var $ = (function () {
FUNCTION EL () {}
el.prototype.elements = [];
el.prototype.add = FUNCTION (ELEMENT) {
this.Elements.Push (Element);
Return this;
};
RETURN FUNCTION (ELEMENT) {
RETURN NEW EL (). Add (Element);
};
}) ();
var a = document.getelementByid ('test');
var b = $ (a);
Console.log (A, B);
(i.e. not at all)
Answer 2, Authority 67%
Language One – JavaScript, EVENING This is only one. This indicates the call context.
When you write $ (this), the f-ya jQuert.fn.init is called, it is very scary, but in the end returns Normal jQuery object . Those item points to a code, and jQuery object has the properties of Length and Context.
Answer 3
this - pure js
$ (this) - jQuery
For example, if you use this to function, then the jQuery chain of functions will not work. A chain of functions of pure js
will work