JSFiddle - React, Tailwind, and code Playground

HTML

How to increment a value of the table cells (like: 1,2,3 etc)?


<div id="table">
<table>
    <tr>
        <td>1.</td>
        <td>--------------------------------------------</td>
    </tr>
    <tr>
        <td>2.</td>
        <td>--------------------------------------------</td>
    </tr>
    <tr>
        <td>4.</td>
        <td>--------------------------------------------</td>
    </tr>
</table>
</div>

Why 0?

CSS

#table td {
    border: 1px solid #DDD;
}

JavaScript

$('#table').find('td:nth-child(1)').each(function(i)
                                         {
                                             $(this).text(i + 1);
                                         });