derrida
asked on
add a class to an li element while looping
Hi
i have an ajax call and i loop it and present it. all this works. the issue: i create the li element, and i need to add a class only to the odd ones.
how to do it?
here is the code i have:
best regards
i have an ajax call and i loop it and present it. all this works. the issue: i create the li element, and i need to add a class only to the odd ones.
how to do it?
here is the code i have:
for(var ii=0;ii<data.length;ii++) {
//alert(data[ii].date);
var li = '<li>
<div class="timeline-badge">
<i class="fa fa-exclamation-circle"></i>
</div>
<div class="timeline-panel">
<div class="timeline-heading">
<h4 class="timeline-title">'+data[ii].thetype+'</h4>
<p>
<small class="text-muted">
<i class="glyphicon glyphicon-time"></i>'+data[ii].date+'
</small>
</p>
</div>
<div class="timeline-body">
<p>'+data[ii].message+'</p>
</div>
</div>
</li>';
$("#alertitin").prepend( li );
}
best regards
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER