Thanks for the help, Klaus. :o)
Rey...
Klaus Hartl wrote:
>
> Rey Bango schrieb:
>
>>Maybe someone could shed some light on this. When inserting an item into
>>a select box (id=test), this code works:
>>
>>var optn = document.createElement("OPTION");
>>optn.text = $(this).find('nome').text();
>>optn.value = $(this).find('id').text();
>>$( "#test" ).append(optn);
>>
>>But this code does not:
>>
>>$( "<option value='" + $(this).find('id').text() + "'>" +
>>$(this).find('nome').text(); + "</option>" ).appendTo( "#test" ) ;
>>
>>Even this very simplistic example doesn't work.
>>
>>$( "<option value='1'>foo</option>" ).appendTo( "#test" ) ;
>>
>>I remember John Resig telling me that I can create elements on the fly
>>by using syntax similar to this;
>>
>>$( "<option value='1'>foo</option>" ).appendTo( "#test" ) ;
>>
>>so I'm not clear why its not working.
>>
>>Any help would be appreciated.
>>
>>Rey...
>
>
>
> In IE the innerHTML property for a select element is readonly, so we
> have to stick to createElement or the Option constructor here...:
>
> $('#test')[0].add(new Option(text, value));
>
>
> -- Klaus
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/