Is there a particular method/plugin you are wanting to write this for? Most jQuery methods and plugins operate on 0 or more matched elements. -- Brandon Aaron
On Fri, Aug 22, 2008 at 7:54 AM, James <[EMAIL PROTECTED]> wrote: > > Hi, > > I can't seem to find anything that does the following: > > $("img").exists(function(matches) { > /* do something with matches */ > }); > > the difference between "exists" and "each" being it is only run once > and supplies all the matches as an argument. > > The long-hand way of doing this is something along these lines: > > var matches = $("img"); > if (matches.length) { > /* do something */ > } > > Before I write myself a quick plugin, is there an obvious alternative > I've missed??? > > Regards, > > James > > > > > >