I'm echoing out a number of div
tags dynamicaly like:
foreach($applications as $application){
$id = $application->user_id;
echo '<div class="col-md-4" id="'.$id.'">',
'<h4 class="list-group-item-heading remove-margin">
<i class="fa fa-plus fa-fw" id="'.$id.'"> </i>
</h4>',
'</div>';
}
i want to make it so that when a user clicks the plus button in a selected div, then only that div is affected. So far when I do that, it affects the elements in sequential order, nomatter which plus I click. here's the jQuery:
$(document).ready(function(){
$('.fa-plus').click(function(){
counter = 0;
id = $(this).closest('div').prop("id");
counter = counter+1;
$(this).css('color','green');
$('#votes-count').parent().html(counter);
alert(id);
});
});