I have a PHP loop like this <?php foreach ($products as $product) { ?> now inside this loop I will be creating some div. the number of divs created depends on number of products. Also, I have a javascript function that creates a countdown.
Now I am trying to create a unique countdown in every div that gets created. .ie unique countdown for every product. here is the code that generates the coundown
$(function(){$('.counter').countdown({startTime:"<?php echo $product['time']; ?>" });});
and this is what I have inside the php loop that creates the divs
<div class= 'counter' ></div>
now what this gives me is the same counter in all the divs. I'm new to all this, I haven't slept in hours trying to learn and figure out what I'm doing wrong.
EDIT:
So I still have not get what I want.
$('.counter').each(function() { $(this).countdown(....
produce the same counter for all the divs. and for some reason I get syntax error when I try to use
$('#product-').countdown(...
in order to create a unique selector.