Is there a simple way to count the unique cells in a column (or row) in an HTML table with jQuery or plain Javascript?
Example: (table with only one column)
melon
banana
melon
strawberry
The counter would be 3.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try this:
For HTML:
This will work for first column. If you want to count values in second column you would use selector
table tr td:first-child+td, for thirdtable tr td:first-child+td+td, etc.Working example: http://jsfiddle.net/7K64j/1/