[jQuery] Unable to have a selected option in list when appended, but why?

[jQuery] Unable to have a selected option in list when appended, but why?


Hi there.
I hava a function which looks like this:
var insertMontNamesIntoSelect = function(selectedList, selectThis)
{
    $(selectedList).empty();
    var str = '';
    for(var i=1; i<13; i++){
        str += '<option value="'+i+'"';
        if(i == selectThis)
            str += ' selected ';
        str += '>'+returnMonthName(i)+'</option>';
    }
    $(selectedList).append(str);
}
The only thing it does is to build a selectable list of danish month
names.
My problem is that it wont select the <option> which has selected as
an attribute.
<select class="selectInput" name="periodMonth">
<option value="1">Januar</option>
<option value="2">Februar</option>
<option value="3">Marts</option>
<option value="4">April</option>
<option selected="" value="5">Maj</option>
<option value="6">Juni</option>
<option value="7">Juli</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">Oktober</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
is the code which is generated by the function. And if I cp it into a
different doc, it works just fine. Then "Maj" will be selected by
default.
But not when jQuery creates the list.
But why?