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].
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.
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>显示数组中的各个元素 Hello
2, Old version
In the old version of jquery, you can use thesize()method to get the size of the array length. (The new version of JQ has removed the size method)
console.log($("li").size());
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!