Home>Article>Web Front-end> Why can’t size be used in jquery?

Why can’t size be used in jquery?

Joseph Gordon-Levitt
Joseph Gordon-Levitt Original
2022-05-18 15:04:12 2071browse

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()

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

Syntax

$(selector).length

The example is as follows:

    123   
  • Coffee
  • Milk
  • Soda

Output result:

Why can’t size be used in jquery?

After clicking the button:

Why can’t 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!

Statement:
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