$ ('# SomeElement') and $ ('# someElement') [0]. This statement has puzzled me for a period of time, at the beginning, I always change one of them to another when an error occurs,
Although the function can be completed every time, it is always hard to say! Later, I finally understood the principle: $ ('# someElement'), although only elements are selected, it is still a package set,
You cannot use DOM node methods (such as SetAttribute ). $ ('# SomeElement') [0] returns the first element in the wrapper set. All methods that can use DOM nodes are returned.
In short: when using JQuery, pay attention to the differences between the packaging set and the DOM node. The methods provided by JQuery are the method of the packaging set, and the JQuery method cannot be used on the DOM node,
Similarly, the DOM node method cannot be used in the packaging set, but can only be applied to DOM nodes. Of course, in addition to methods, there are also attributes (such as innerHTML ).
At the same time, I can package DOM nodes into packaging sets. For example, we often use $ (this) to package nodes into packaging sets and then use JQuery to process them.