there are different operations inside two simple calls ... the magic exists thanks to those operation but obviously 4000 options are not that simple to manage, specially in IE.
As you spotted DOM is almost real-time, that is the cost to use whatever library, but in this case you can combine both trying something like: 1 - $("#mySelect").find("option").filter(function(){return !!this.selected}).text() 2 - $($("#mySelect")[0].getElementsByTagName("option")).filter(function(){return !!this.selected}).text() 3 - var text = []; $("#mySelect").find("option").each(function(){if(this.selected)text.push($(this).text());}); In any case, I think a select with multiple="true" and 4000 options is everything but user friendly ... but it does not matter if you need it. Regards On Mon, Sep 21, 2009 at 3:50 PM, matthew_maxwell <leftwithoutli...@gmail.com > wrote: > > I've been using jQuery for a little bit now, and have noticed that > whenever you are attempting to use jQuery on selects with a large > amount of options, it adds a few seconds of lag to the operation. > > An example I ran into was when I had a select of about 4,000 options > or so (one for every user of my site), and wanted to use jQuery to > change from a select to a plain text field, using the following: > > $("#user").html( $("#mySelect").find("option:selected").text() ); > > The time from when the user initiates the change until it actually > completes is about 1 or 2 seconds. > > I notice there's also a delay when it goes to add the select back: > > $("#user").html( > $( myApp.Selects.Users.HTML ).change( > function () { > $("#user").html( $("#mySelect").find > ("option:selected").text() ); > } > ) > ); > > The lag time also appears when I go to do a simple remove: > $("#mySelect").remove(); > > When I use the DOM equivalents, though, this works almost instantly. > > Just figured I'd give you a heads up. > > No other issues, though. Solid library. Good work. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---