Adding selected="selected" in the input

0
I have a loop in js with <select> and <option> , I need to set selected to <option> , but since it is in the loop I can not add directly to this <option> , have any suggestions or tip?

Follow the code:

var $html = "<select class='form-control' name='usuario' id='usuario'>";
for( var i in data ){
    var u = data[i];
    $html += '<option value="'+ u.login +'">' + u.login + '</option>';
}
$html += '</select>';
    
asked by anonymous 25.10.2015 / 02:04

0 answers