I have a grid of let's say 12 cards, 4 columns and 3 rows. Every column has a different class. Column 1: has class a. Column 2: has class b and so on c and d.
If I loop through all cards with the class of a, I can know their row position because jquery's for each has an index.
My problem is when someone clicks a card let's say column b row 2 how can we get the index then, I know it's in column 2 because it has a class of b, but how do I know which row it is?
What I need is a math function that I can pass in let's say 7 (if the 7th card was pressed) and it will return 2 (because it's in the second row) , and for 10 it will return 3.
I used for an example 12 cards but this math function should return for any amount of cards.