'How to select a classes with same name without using incremental id

enter image description hereIs there other ways to select classes with same name but in different table rows? I use html class="className + id" Than in jquery to select $('.className'+id)... some code I would like to avoid using the id each time. Some suggestions? Thank you

HMTL
Data retrieved from the database
<tr class="row" id="<?= $id;?>"> <!-- id 1 -->
   <td  class="atyp<?= $id;?>"> <?= $v['atyp'];?> </td>

 <tr class="row" id="<?= $id;?>"> <!-- id 2 -->
   <td  class="atyp<?= $id;?>"> <?= $v['atyp'];?> </td>

JQUERY
<script>
$('.atyp'+id).val() // some code....
</script>

So the table has multiple rows with same class name and I would like to avoid to use id to select a specific class



Solution 1:[1]

You should not give multiple HTML elements the same ID.

You can select the first td with the :first-of-type selector

$("td:first-of-type")

In general you can use the :nth-of-type selector.

$("td:nth-of-type(42)")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Script Raccoon