I am trying to create new div element and then change it`s position with Jquery.But J query effects only first element.I want to change all elements position with different number.
<div class="userList">
<?php $categories = find_category();
foreach($categories as $category): ?>
<div id="user">
<img id="<?php echo $category['cat_id']; ?>" src="<?php echo $category['cat_image']; ?>" />
<a></a>
</div>
<?php endforeach ;?>
</div>
If I make in Jquery like
var a= 60;
$(".userList").children().css({'left':a+'px' ,'top':a+'px'});
a+=60;
This changes all <div id="user">
to <div id="user" style="left: 60px; top: 60px; ">
But I need to make first one left:60px top:60px and next one left:120px top:120px.
I also used .each function like
$(".userList").each(function(){
$("#user").css({'left':a+'px' ,'top':a+'px'});
a+=60;
});
But this time only first <div id="user">
changed to <div id="user" style="left: 60px; top: 60px; ">
And the other does not effected.