Why can't size be used in jquery?

WBOY
Release: 2022-05-18 15:04:12
Original
2074 people have browsed it

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".

Why can't size be used in jquery?

The operating environment of this tutorial: windows10 system, jquery3.2.1 version, Dell G3 computer.

Why size cannot be used in jquery

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()
Copy after login

The length property contains the number of elements in the jQuery object.

Syntax

$(selector).length
Copy after login

The example is as follows:

    123   
  • Coffee
  • Milk
  • Soda
Copy after login

Output result:

Why cant size be used in jquery?

After clicking the button:

Why cant size be used in jquery?

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!