This time I will show you how to use jQuery length and size(), and what are the precautions for using jQuery length and size(). The following is a practical case, let's take a look.
1.length is theattribute, and size() is the method.
2. If you just want to get the number of elements, the two effects are the same,("img").length and
("img").length The value obtained by
("img").size() is the same.
string or the number of elements in an array, you have to use length, such as $("#text").val(). length.
The .size() method is deprecated as of jQuery 1.8. Use the .length property instead.The .size() method is functionally equivalent to the .length property; however, the .length property is preferred because it does not have the overhead of a function call.As can be seen from the above, size() is implemented by calling the length propertyAfter jquery 1.8, length replaced size() , because length does not need to return a function call, which is better.
Learn from yesterday, live for today, hope for tomorrow.I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other php Chinese websites related articles! Recommended reading:
How to use Vue to achieve drag-and-drop effect
Node.js console output log file example analysis
The above is the detailed content of How to use jQuery length and size(). For more information, please follow other related articles on the PHP Chinese website!