$("[name]","#people") is equivalent to $("#people                [name]").

Please note the spacing.

It then means every element with a name attribute BELOW the element of id
"people".

$("#people[name]") means the element of id "people" with a name attribute.

So, YES, this is quite different.

2009/3/25 DBJ <[email protected]>

>
> @Daniel
>
> You confuse me ;o)
>
> Aa I said : A quick sample I have made (quickly) is here:
> http://jsbin.com/avowu/edit
>
> Please use it now. It is extremely simple and it shows what is going
> on inside jQuery, regarding : this.selector and this.context.
>
> So when I say: $("[name]", "#people"); I can (and you) can see that
> inside jQuery selector (aka this.selector) is : "'#people[name]"
>
> So I am not "thinking" on this one I am just passing it on. This is
> also very confusing:
>
> > Thinking that $("[name]", "#people"); is the same as $("#people[name]");
> > is wrong on multiple levels.
>
> This is how I understood jQuery documentation describes the context,
> but this is not
> apparently how this.selector value is defined inside ... This might be
> "wrong on multiple levels" bi this is the value of this.selector , as
> we can clearly see.
>
> Also you say :
>
> > $("[name]", $("#people")); actually means  $("#people [name]");
>
> Are you actually saying this is the proper usage? Ok, but why is than
> the "improper" usage allowed? If it is imporper that is.  But the
> question (for the last snippet) is what is then the value of the
> this.slector going to be, when  used by a plugin ? Currently it is :
> "#people [name]"
>
> Also, why are we in this mess ? Can we have consistent documentation
> and implementation that is folllowing it?  Something like :
>
> "Context type can be a dom node or an jQuery instance. Everything else
> throws an exeception if passed as a context to the jQuery() function"
>
> This would be a really good start to the discussion on what is
> actually a "context" ;o)
>
> Regards.
>
>
> 2009/3/25 Daniel Friesen <[email protected]>:
> >
> > Context is either a dom node, a document, or recently a jQuery object
> > with the like. Context is merely used for establishing a dom node as a
> > parent, and in the case of a document is necessary to know what document
> > to use to create new nodes for.
> > Thinking that $("[name]", "#people"); is the same as $("#people[name]");
> > is wrong on multiple levels. $("[name]", $("#people")); actually means
> > $("#people [name]"); and the contex is not meant to be used that way.
> > In fact trying to think that way makes things confusing and reduces code
> > readability because you are mixing up order. If you want to build
> > queries like this then I'd recommend you push for the inclusion of my
> > alternate proposed format:
> > $("#selector", "[selector]", ".selector", ...);
> > Which makes proper sense since you are building up selectors in order
> > (even has potential performance benefits if someone is adventurous since
> > I'd explicitly say to not rely on any consistent return for .end() when
> > using it). It's even more useful when you throw widget objects into the
> mix.
> >
> > ~Daniel Friesen (Dantman, Nadir-Seen-Fire)
> >
> > DBJDBJ wrote:
> >> My question/comment : What is a CONTEXT LOGIC in jQ ? I think it
> >> should be : dom node inside which is the result set to be found?
> >> The dom node inside which is jQuery to use the selector given. Default
> >> is document.
> >>
> >> If I read it right , jQ doc says that context type can be (only?) dom
> >> node or jQuery instance. So I expected that if I give context as a
> >> string it will be takens as selector for the jQuery, which will
> >> eventualy spill out a single dome node to be used as a context. And
> >> that
> >> way one can speed up her code, because querying inside the known dom
> >> element must be quicker than querying inside the whole document, each
> >> time. finding on the branch is faster that finding from the root of
> >> the tree.
> >>
> >> But it seems that if string is given as a context , the selector get's
> >> it as a prefix and context is a dom document ? So :
> >>
> >> $("[name]", "#people")    is the same as saying    $("#people[name]",
> >> document ) , because jQ makes it into this.
> >>
> >> While one might expect the above to be translated to :  $("[name]",
> >> document.getElementById("people") ) , which could considerably speed
> >> up the slection ...
> >>
> >> A quick sample I have made (quickly) is here:
> http://jsbin.com/avowu/edit
> >>
> >> // context is correctly reported by jQ
> >> $("[name]", document.getElementById("people")).formula( log ) ;
> >>
> >> // this.context is reported by jQ as HTMLDocument ?
> >> // this.selector is prefixed with context
> >> $("[name]", "#people") ;
> >>
> >> Is this "by design" ?  Maybe jQ does this :
> >>
> >> 1 :: jQuery("#people").find("[name]")
> >> 2 :: this.context = "#people" + "[name]"
> >>
> >> So that plugins can see the context which actually was used ? So the
> >> line :
> >> $("[name]", "#people")
> >> after all IS actually making things faster ? And I am (or I was)
> >> confused with the value of this.context and this.selector, available
> >> to me inside a plugin ? But then I think I can;t be right here,
> >> because it would be much better to have the selector and context, as
> >> originaly
> >> given by the user :
> >>
> >> 1 :: this.context = "#people" ; this.selector = "[name]" ;
> >> 2 :: jQuery(context).find(selector)
> >>
> >> After this plugins will see the original selector and context.
> >> Provided my assumptions are correct.
> >>
> >>
> >>
> >>
> >>
> >>
> >> >
> >>
> >
> > >
> >
>
>
>
> --
> Dusan Jovanovic
> http://dbj.org
> -------------------------
> "html e-mail is expensive" ™
>
> This email originates from Dusan B. Jovanovic. It, and any
> attachments, may contain confidential information and may be subject
> to copyright or other intellectual property rights. It is only for the
> use of the addressee(s). You may not copy, forward, disclose, save or
> otherwise use it in any way if you are not the addressee(s) or
> responsible for delivery. If you receive this email by mistake, please
> advise the sender and cancel it immediately. Dusan B. Jovanovic may
> monitor the content of emails within its network to ensure compliance
> with its policies and procedures. Any email is susceptible to
> alteration and its integrity cannot be assured. Dusan B. Jovanovic
> shall not be liable if the message is altered, modified, falsified, or
> edited.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to