I have the following code:
for (i = 0; i < 13; i++){
$('.players').append('<div class="rule_dropdown"><select name="rule' + i + '">');
for(j = 0; j < rules.length; j++){
$('.players').append('<option>' + rules[j] + '</option>');
}
$('.players').append('</select></div>');
}
I want to have 13 dropdown lists with the same content. I expect this to happen:
- First for loop add an opening div and select
- For each rule in rules array, append an option
- Add closing select and closing div
- Go back to #1
But this is what actually happens:
- First loop add opening AND closing div and select.
- Second loop add option with the right content
Does anyone know why?