0
I’m selecting a select and trying through the array to access one of the options to place it with the attribute Selected, but every time I try to use the .att("selected", "selected");
get the bug: TypeError: size[0][1].attr is not a function
Select:
<select id="size" name="size" class="selectpicker" data-title="Tamanho" data-style="btn-default btn-block" data-menu-style="dropdown-blue">
<option value="PP" >PP</option>
<option value="P">P</option>
<option value="M">M</option>
<option value="G">G</option>
<option value="GG">GG</option>
<option value="XGG">XGG</option>
<option value="XXXG">XXXGG</option>
</select>
Jquery:
var size = $("#size");
size[0][1].attr('selected', 'selected');
Error:
TypeError: size[0][1].attr is not a function
What would be the index?
– Luhan Salimena
It would be the position of the option you would like to select, what you intended with
$(size[0][1]).attr('selected', 'selected');
?– Leandro Angelo