I am trying to select programmatically an option from a HTML Select which is filled dynamically by code.
The selected is filled with a for:
for(var i =0; i< valores.length ; i++)
{
var opcion= "<option value="+valores[i]['id_estado']+">"+valores[i]['nombre_estado']+"</option>";
selectEstado.append(opcion);
}
and then select a option with:
$("#select_estado option[value='"+valores[0]['estado']+"']").attr('selected', true);
but when I do the select locates in the value=0, any ideas?