Do you mean the $( 'selector', context)? By default $() searches the document, the document is the context. If you add a second argument that is a DOM element or a jQuery object then they become the context, and it searches "inside" them.
For more info I suggest: http://docs.jquery.com/Core Or Visual jQuery: http://www.visualjquery.com/ Karl Rudd On 2/13/07, Daemach <[EMAIL PROTECTED]> wrote: > > Hmm - I haven't seen a selector used like that before - where do I find more > information on how that works? > > Thanks again - I figured there was an elegant solution. > > > Karl Rudd wrote: > > > > $('#theSelect').bind( 'change', function() { > > var list = []; > > $('option:selected', this).each( function() { list.push( this.value ) } > > ); > > // do something with 'list' here > > }); > > > > Karl Rudd > > > > On 2/13/07, Daemach <[EMAIL PROTECTED]> wrote: > >> > >> OK that makes sense. Now how do I bind that function to the onChange > >> event > >> of the select list? > >> > >> Thanks btw - I am just trying to learn :) > >> > >> > >> > >> Karl Rudd wrote: > >> > > >> > Technically two "lines". > >> > > >> > var list = []; > >> > $('#theSelect option:selected').each( function() { list.push( > >> > this.value ) } ); > >> > > >> > Note that each option should have a value attribute for this to work. > >> > > >> > Karl Rudd > >> > > >> > On 2/13/07, Daemach <[EMAIL PROTECTED]> wrote: > >> >> > >> >> I'm actually after an array of the values of those selected options. > >> >> Like a > >> >> coalesce over the values. I can do it with a loop, but I'm hoping > >> there > >> >> is > >> >> a more elegant solution. > >> >> > >> >> > >> >> > >> >> Karl Rudd wrote: > >> >> > > >> >> > If you just want an array of selected options: > >> >> > > >> >> > $('#theSelect option:selected') > >> >> > > >> >> > You could use the form plugin if you wanted to do something more: > >> >> > > >> >> > http://www.malsup.com/jquery/form/ > >> >> > > >> >> > Karl Rudd > >> >> > > >> >> > On 2/13/07, Daemach <[EMAIL PROTECTED]> wrote: > >> >> >> > >> >> >> I know I can loop over all the options in a select object, checking > >> to > >> >> >> see if > >> >> >> they are selected and add their values to an array if so. I would > >> >> love > >> >> >> to > >> >> >> see how JQuery could tackle this though. In other words, I want > >> to > >> >> end > >> >> >> up > >> >> >> with an array of all of the selected object's values in one line of > >> >> code. > >> >> >> -- > >> >> >> View this message in context: > >> >> >> > >> >> > >> http://www.nabble.com/selector-gurus%3A-how-can-I-create-list-of-all-selected-elements-values.-tf3218532.html#a8938311 > >> >> >> Sent from the JQuery mailing list archive at Nabble.com. > >> >> >> > >> >> >> > >> >> >> _______________________________________________ > >> >> >> jQuery mailing list > >> >> >> discuss@jquery.com > >> >> >> http://jquery.com/discuss/ > >> >> >> > >> >> > > >> >> > _______________________________________________ > >> >> > jQuery mailing list > >> >> > discuss@jquery.com > >> >> > http://jquery.com/discuss/ > >> >> > > >> >> > > >> >> > >> >> -- > >> >> View this message in context: > >> >> > >> http://www.nabble.com/selector-gurus%3A-how-can-I-create-list-of-all-selected-elements-values.-tf3218532.html#a8938539 > >> >> Sent from the JQuery mailing list archive at Nabble.com. > >> >> > >> >> > >> >> _______________________________________________ > >> >> jQuery mailing list > >> >> discuss@jquery.com > >> >> http://jquery.com/discuss/ > >> >> > >> > > >> > _______________________________________________ > >> > jQuery mailing list > >> > discuss@jquery.com > >> > http://jquery.com/discuss/ > >> > > >> > > >> > >> -- > >> View this message in context: > >> http://www.nabble.com/selector-gurus%3A-how-can-I-create-list-of-all-selected-elements-values.-tf3218532.html#a8938839 > >> Sent from the JQuery mailing list archive at Nabble.com. > >> > >> > >> _______________________________________________ > >> jQuery mailing list > >> discuss@jquery.com > >> http://jquery.com/discuss/ > >> > > > > _______________________________________________ > > jQuery mailing list > > discuss@jquery.com > > http://jquery.com/discuss/ > > > > > > -- > View this message in context: > http://www.nabble.com/selector-gurus%3A-how-can-I-create-list-of-all-selected-elements-values.-tf3218532.html#a8939611 > Sent from the JQuery mailing list archive at Nabble.com. > > > _______________________________________________ > jQuery mailing list > discuss@jquery.com > http://jquery.com/discuss/ > _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/