I'd like to apply jQuery to classes that are generated dynamically as they are looped through PHP/MySQL.
I've got a non-dynamic working version on JSfiddle: jsfiddle.net/TXJA5/1/
In the example, cat_fruit, cat_vegetable and cat_cereal would be echoed within a PHP loop; something like:
<div class="category cat_<?php echo $category; ?>">
<p><?php echo $category_label; ?></p>
</div>
Then, in following columns, there will be divs containing items associated to the category:
<div class="column">
<div class="item cat_<?php echo $category; ?>">
<p><?php echo $item[0]; ?></p>
<p><?php echo $item[0]; ?></p>
</div>
</div>
So, why? Well, while the data is variable and "categories" exist in one column and "items" exist within other columns in another div, I need the associated divs to be identified by jQuery to make them the same height (using equalizeCols — see the fiddle; you'll get it.)
n.b. There's a reason this isn't a table, despite the obvious column/row relationships. I considered it (fretfully) and tried it, but it won't work for the needs of the actual project.
Thanks in advance for any help you can offer. This is my first question on SO after years of learning from it — this community is awesome. I've found a couple questions on here that may make mine look like a duplicate, but they couldn't quite help get me there!