On Jan 28, 2008 1:23 PM, Klaus Hartl <[EMAIL PROTECTED]> wrote: > Try this: > > var opts = $( 'option', select ); > opts = opts.add( $('<option>New option</option>').appendTo(select)[0] );
Ah! I see what I was doing wrong. I thought mistakenly that the add method modified opts in situ, so I was not assigning its returned value to opts... So this is what I have now (CE below is my own bit of syntactic sugar): var opts = $( 'option', select ); var cur_length = opts.length; // add options to select element if necessary if ( new_length > cur_length ) { // array of newly created option elements var os = $.map( new Array( new_length - cur_length ), function () { return CE( 'option' ) } ); opts = opts.add( $( os ).appendTo( select ) ); } Boy, I like this! (The dummy array in the map is a bit of a waste, though...) Anyway... thank you! kynn