Can I count the number of elements with a specific attribute?
For example all the images with the src attribute test.gif
To count all HTML elements, we use length property. The length property is used to count number of the elements of the jQuery object.
We can find the length of the string by the jQuery . length property. The length property contains the number of elements in the jQuery object. Thus it can be used to get or find out the number of characters in a string.
The length property in jQuery is used to count the number of elements in the jQuery object. The size() function also returns the number of elements in the jQuery object.
You can simply use the jQuery . length property to find the number of elements in a DIV element or any other element.
Use the CSS attribute selectors to filter on the attribute
$("img[src='test.gif']").length;
the size() and length both returns the number of elements matched;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With