>  I was avoiding using just $(".newWindow"), or $("#newWindow"), because then 
> jQuery has to search the whole document for that class or ID. Whereas if I 
> use $("a.newWindow") or $("a#newWindow"), it's faster because jQuery then 
> only examines the A tags, and nothing else. Am I right in thinking that. I'm 
> pretty sure I read something to that affect on this list, as some point.
>

Half right, $(".newWindow") selects all tags and searches their
classes for "newWindow". $("a.newWindow") selects all "a" tags and
searches their classes for "newWindow". Fewer tags to search so the
a.newWindow version is faster. In the case of $("#newWindow"), jQuery
uses the browser's native document.getElementById function to go
straight to the correct element. $("a#newWindow") selects all "a"
tags, then searches them for the one who's id is "newWindow", so it's
actually slower than $("#newWindow").

But in your case, you're probably going to have more than one
"newWindow", so you want a class.

>  So I'll use $("a.newWindow").click(... as my selector. Does that sound about 
> right? Is it the best approach?

Yes.

--Erik

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to