I have a number of elements on my page that belong to classes with unique identifiers, based on my backend programming. Such that I may have the following:
<element class="element-1"></element>
<element class="element-1"></element>
<element class="element-2"></element>
<element class="element-2"></element>
<element class="element-3"></element>
<element class="element-3"></element>
Is there a way I can count the unique occurrences of these classnames with jQuery, so that whatever function would do that would return 3
?
the answer is much simpler: $("element.element-1").length;
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