Jquery counting elements by class what is the best way to implement this?
Posted
by 133794m3r
on Stack Overflow
See other posts from Stack Overflow
or by 133794m3r
Published on 2010-04-28T06:40:59Z
Indexed on
2010/04/28
6:43 UTC
Read the original article
Hit count: 224
Ok what i'm trying to do is to count all of the elements in the current page with the same class and then i'm going to use it to be added onto a name for a input form. Basically i'm allowing users to click on an and then by doing so add another one for more of the same type of items. But i can't think of a way to count all of these simply with jquery/javascript.
I was going to then name the item as something like name="whatever(total+1)", if anyone has a simple way to do this i'd be extremely grateful as javascript isn't exactly my native tongue and stack overflow usually has a ton of great answers and a great community so i'm hoping my query will not go unheard.
© Stack Overflow or respective owner