How to get the length of an array in jquery

coldplay.xixi
Release: 2023-01-04 09:36:52
Original
4105 people have browsed it

How to get the length of an array in jquery: You can use the length attribute to get the length of the array. The length attribute contains the number of elements in the jQuery object. The attribute syntax is [$(selector).length].

How to get the length of an array in jquery

The operating environment of this tutorial: windows7 system, jquery3.2.1 version, thinkpad t480 computer.

Recommended:jquery video tutorial

##Method to get the array length in jquery:

1. In the new version of

jquery, you can use the length attribute to get the length of the array. The length attribute contains the number of elements in the jQuery object. The attribute syntax is

$(selector).length.

Example:

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>     显示数组中的各个元素    

Hello

Copy after login

2, Old version

In the old version of jquery, you can use the

size()method to get the size of the array length. (The new version of JQ has removed the size method)

The usage method is as follows:

console.log($("li").size());
Copy after login

Related free learning recommendations:javascript(video)

The above is the detailed content of How to get the length of an array 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!