IDs are supposed to be unique per the spec. jQuery shouldn't have to
hack/deal with invalid markup.

--
Brandon Aaron

On 10/10/06, Christof Donat <[EMAIL PROTECTED]> wrote:
> Hi,
>
> > > Well, you might whant to work with an element only if it is inside
> > > another one, which you already have:
> >
> > Unfortnuately, getElementById exists only for the document object,
> > therefore you can't just say context.getElementById(...). I think this
> > is the reason why jQuery can't help you there.
>
> I know.
>
> JQuery could check if context.getElementById exists and if it doesn't walk the
> elements in the context and return the first Element it finds that has the
> given ID:
>
> if( context.getElementsById ) elems = [context.getElementsById(id)];
> else {
>         var f = function(i,c) {
>                 if( c.id == i ) return [c];
>                 for( ch in c.childNodes ) {
>                         if( ch.nodeType != 1 ) continue;
>                         var r = f(i.ch);
>                         if( r.length > 0 ) return r;
>                 }
>                 return [];
>         }
>         elems = f(id,context);
> }
>
> That means that for browsers with a good implementation of getElementById()
> $('#myid',context) is much slower than $('#myid'), but it returns the
> expected result. At least that should not be slower than
> $('.myclass',context).
>
> Christof
>
> _______________________________________________
> jQuery mailing list
> discuss@jquery.com
> http://jquery.com/discuss/
>

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to