How can I select a specific jquery element value from inside a loop? <p>I am trying to put a string value in an array based on their position in relation to all of the elements with a class name. I get an array of the indexes that I want to use now I want to use each of the index values to select the appropriate value. </p> <pre><code>$(function () { $("#date").datepicker(); $('input[name=date]').datepicker(); var dateInput = $("select[name='searchString']"); var theClassTime = $("input.TextBoxDate"); var checkedindex = []; var classday = []; $("input[name='selectedCourses']").each(function (i) { if (this.checked) { // this works fine checkedindex.push(parseInt(i)); // this is where I’m trying to select values based on index. var dayofclass = $(".TextBoxDate:eq(" + checkedindex[i] + ")"); classday.push(dayofclass); alert(classday); } }); }); </code></pre> <p>Say checkedindex has values: 2,3,9 meaning at index 0 of checkedindex is 2, at 1=3 and at 2=9. I want to use 2, 3 and 9 to do something like this:</p> <pre><code>var dayofclass = $(".TextBoxDate:eq(" + checkedindex[i] + ")"); </code></pre> <p>What am I doing wrong here?</p>