Home>Article>Web Front-end> Why can’t size be used in jquery?
Because size was abandoned in jquery version 1.8, the size method cannot be used in versions after 1.8; this method can return the number of elements matched by the jquery selector and can be replaced by the length attribute, which contains The number of elements in the jquery object, the syntax is "$().length".
The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.
The size() method was deprecated in jQuery version 1.8. Please use the length property instead.
The size() method returns the number of elements matched by the jQuery selector.
Syntax
$(selector).size()
The length property contains the number of elements in the jQuery object.
Syntax
$(selector).length
The example is as follows:
123
Output result:
After clicking the button:
Recommended related video tutorials:jQuery video tutorial
The above is the detailed content of Why can’t size be used in jquery?. For more information, please follow other related articles on the PHP Chinese website!