Marius Vasile

Marius Vasile

  • 588
  • 1.7k
  • 124.6k

loop through records with letters as variable

Aug 19 2023 8:55 AM

I can loop through records with

$("#btnVerTest").on("click", function () {

    for (let i = 1; i <= 3; i++) {

        if ($("#txtCor" + i).text() == "DA") {
            $("#inputRasCor").val($("#txtRas" + i).text());
            $("#inputCor").val($("#txtCor" + i).text());
        }
    };
})

where txtCor has id from 1 to 3.

How can I loop through records if all id's have letters instead of numbers, A, B and C? txtCorA, txtCorB, txtCorC and so on

 


Answers (4)