Thanks everyone! :o)

It looks like you're all saying the same thing. Using the class as an identifier on the A tag is faster, and duplicate IDs are bad (which I kinda knew already, but wasn't sure about the proper usage of the class attribute). So I should stick with (in this case at least) using a class to identify the A tags that I want to open in new windows.

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.

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

Thanks,
Chris

Klaus Hartl wrote:
Alex Cook schrieb:
Yep, you’ve got it… tho if there are multiple links on the page you want this too happen with, class is better, two of the same IDs on a page is bad. Regardless of the class being in the CSS file or not, it’s a unique identifier for a group of elements.

Yes, the class attribute isn't only meant to be a style sheet selector:

"The class attribute, on the other hand, assigns one or more class names to an element; the element may be said to belong to these classes. A class name may be shared by several element instances. The class attribute has several roles in HTML:

* As a style sheet selector (when an author wishes to assign style information to a set of elements).
     * For general purpose processing by user agents.
"

http://www.w3.org/TR/html401/struct/global.html#h-7.5.2

Wow, I should get money everytime I post that quote on this list :-)



- Klaus


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

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

Reply via email to