Just for the record, ignoring performance and the invalid IDs, this
could be done with filter():

$('span.class').filter(function(){
    return this.id < y;
});

cheers,
- ricardo

On Aug 31, 6:57 pm, aquaone <aqua...@gmail.com> wrote:
> indeed. there's gotta be a better solution than this.
> if you can't control it and insist on using this method,
> $(span.class).each(function(){if($(this).attr('id')<x){//do something}});
> The performance on that will be crap. Please find an alternate solution e.g.
> .is(':gt'+x)
>
> aquaone
>
> On Mon, Aug 31, 2009 at 14:47, Josh Nathanson <joshnathan...@gmail.com>wrote:
>
>
>
> > Any chance of doing what you need to do on the server, rather than the
> > client?
>
> > Are you stuck with the naming convention you're using, or can you name the
> > spans a little differently or give them different class names to allow for
> > better selection criteria?
>
> > Given your current situation you'd have to loop through each span as
> > Aquaone
> > said, but I bet you might be able to think of a different way to approach
> > the problem.
>
> > -- Josh
>
> > -----Original Message-----
> > From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On
> > Behalf Of Namir
> > Sent: Monday, August 31, 2009 2:33 PM
> > To: jQuery (English)
> > Subject: [jQuery] Re: jQuery select where attribute ID less than
>
> > Still how would I do it with an each? I'd still need to select all the
> > ones with an attribute of less than x, and it would be stupid to loop
> > it from 1 to whatever as x can reach thousands. Do you have any other
> > suggestions as to how I could do this?
>
> > On Aug 31, 9:58 pm, aquaone <aqua...@gmail.com> wrote:
> > > id will be a string. AFAIK there's no built-in to parse it as a number
> > and
> > > compare. you'd either have to .each() it or find another means of
> > > accomplishing what you are trying to do.
>
> > > aquaone
>
> > > On Mon, Aug 31, 2009 at 13:50, Namir <namiras...@hotmail.com> wrote:
>
> > > > How can I do a less than in a select e.g. something like $.("span.class
> > > > [id<"+ a_custom_variable +"]") when I tried that it just selected all
> > > > span of class with an ID attribute rather than where ID attribute is
> > > > less than

Reply via email to