4
Answers

loop through records with letters as variable

Marius Vasile

Marius Vasile

1y
501
1

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)