I have a page of database results as list items, each result having between none and several possible css classes dynamically assigned (but not known), for filtering purposes.
Using jQuery how do I programatically find what classes are assigned to each li, AND count the frequency of each class appearance on the page?
I need to be able to access them by the name of the css class, to update html on the page.
Ex html
<ul class="results">
<li class="a b c d>...</li>
<li class="a c>...</li>
<li class="b c f>...</li>
<!— many more li —>
</ul>
The target output is: option a 2 option b 2 option c 3 option d 1 option e 0 option f 1 ...
Where 'option a' is a filter already on the page, and the count would appear beside it. I have the filter ready to accept the html update:
echo ' <span class="' . $row_rsCategories['category'] . '"></span>';
Where the category is the name of the filter.
element.className.split(' ')to get an array of classes for an element, and loop through them counting each class.