mercredi 5 août 2015

eq(0) is not a valid selector with $.each


<select class="qty">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>


<select class="qty">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>

I have 2 select tag and I want to update them with an array, means chaging the selected to correct value, but why in my attempt below eq() is not working with my loop?

selectedArr = [2,3];

$.each(selectedArr,function(i,obj){
console.log(obj);
$('.qty:eq('+i+')').prop('selected',true);
});



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire