Dave's Brain

Browse - Programming Tips - How can I find the number of elements from a jQuery query?

Language: javaScript
Library: jQuery
Date: 2017oct23

Q.  How can I find the number of elements from a jQuery query?

A.
In jQuery 1.0 and later
let n = $('.myclass').length;
In jQuery 1.8 to 3.0
let n = $('.myclass').size();

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.