i have the follow code
$("#tlbQueryConf tr:last").append(
$('<td></td>').append(
$(".ddlFields").clone().attr('id', 'ddlFields-' + conf.id).attr('class', '').val(conf.field)));
So now, what i'm trying to accomplish it's give the attribute selected
to the new element with that value that i selected
i tried like this, but sets the atribute selected
to the element and not the item
$(".ddlFields").clone().attr('id', 'ddlFields-' + conf.id).attr('class', '').val(conf.field).attr('selected',true)
the html that result its the follow
<select name="ctl00$ContentPlaceHolder1$ddlFields" id="ddlFields-1" class="">
<option value="1">Prueba</option>
<option value="2">cantidad de fallas</option>
<option value="3">nº</option>
<option value="4">Ciudad</option>
<option value="5">COID</option>
<option value="6">COID_DESC</option>
<option value="7">Creado_EN</option>
<option value="8">DSLAM PROVEEDOR</option>
</select>
Note
even using val()
the property selected
it's not set to item