i used "foreach" statement to access all items of IEnumerable and present it in details page ....and i want to make float property of each item different from the other items ....so i used jQuery to affects on each item....but when i run the code all items became with the same direction.....how to affects on each item alone and make its direction of first to right and second to left and third to right ...etc?
here is html code:
@foreach (var item in Model.TimeLines)
{
<section id="timeline">
<article>
<div class="inner">
<span class="date">
<span class="day">@item.EventDate</span>
</span>
<h2>@item.Title</h2>
<p>@item.Body</p>
<div class="form-group row col-lg-12">
@*<div class="button_cont row col-lg-6" align="center"><a asp-action="Edit" asp-controller="TimeLines" asp-route-id="@item.Id" class="example_c" noopener">Edit</a></div>*@
<div class="button_cont row col-lg-6" align="center"><a asp-controller="TimeLines" asp-action="Delete" asp-route-id="@item.Id" style="cursor:pointer;" class="example_c" id="del">حذف</a></div>
<div class="button_cont row col-lg-6" align="center"><a asp-controller="TimeLines" asp-action="Edit" asp-route-id="@item.Id" style="cursor:pointer;" class="example_c">تعديل</a></div>
</div>
</div>
</article>
</section>
}
and jQuery code:
<script>
$('section article').each(function (i, element) {
$(element).find('div.inner').css('float', 'right');
element = element.nextElementSibling.nextElementSibling;
$(element).find('div.inner').css('float', 'left');
});
</script>