I am trying to run a script inside my HTML, building a table with data. I have a range of values, and I only want this For Loop to run on the very last item in the range. Here is the code I have started with.
<? for(var i=0;i<rodsAmt.length;i++){ ?>
<? if(i>=rodsAmt.length) { ?>
<tr>
<td><?= rodsAmt[i]; ?></td>
</tr>
<? } ?>
<? } ?>
This is what I needed to do.
<? for(var i=0;i<rodsAmt.length;i++){ ?>
<? if(i==rodsAmt.length-2) { ?>
<tr>
<td><?= rodsAmt[i]; ?></td>
</tr>
<? } ?>
<? } ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.