If you've got many links on the page that you want to open in a new window, then a class is the best way to go. It doesn't matter whether it actually exists in your CSS or not -- if it's in the <a> element's "class" attribute, jQuery will find it.
BTW, $("#newWindow") is alot faster than $("a#newWindow"). See http://aheimlich.freepgs.com/javascript/jquery-selector-speed/ for more info. On 12/15/06, Christopher Jordan <[EMAIL PROTECTED]> wrote:
Ah! That's where I've gone wrong. I knew what I had was all a big cock-up. I did look at the API first, but still couldn't manage to get it to work right. My click function worked just fine (though I know that the "var handle" bit isn't strictly necessary), it's just that *all* of my <a href...> tags were opening via the .click function and not just the couple I wanted. The class isn't one that really exists in a .css file or anything, but just something I added in an attempt to do what you've now explained to me how to do. I had originally had an ID on each of the <a> tags that I wanted opening up in this special way. If I've got this right now, I could do something like: $("a#newWindow").click(function{}); Is that right? I think I'd rather not use a class, since one doesn't really exist that's called "newWindow" (I just arbitrarily put that class on the certain A tags in one of many attempts to get the syntax correct. So, I think the ID on each tag would be better. Have I got that right? Cheers, Chris Alex Cook wrote: Wait, I'm confused… What does .newWindow relate too? The code you're using has jQuery looking for A within .newWindow… Are you trying to find all the A tags with a class of newwindow? If so, the constructer would be $("a.newWindow"). jQuery uses CSS syntax to target things, so if you're unfamiliar with how to select an element with a class, I'd suggest doing some googling on it or read the jQuery.com pages on Expressions. Second, you've constructed the click() function wrong… you don't need the var handle = bit… function () { window.open(this.href, 'some_target', 'width=550, height=550'); } is all you need. -ALEX ------------------------------ *From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]<[EMAIL PROTECTED]>] *On Behalf Of *Christopher Jordan *Sent:* Friday, December 15, 2006 9:40 AM *To:* jQuery Discussion. *Subject:* [jQuery] I need syntax help, please. This should be a quick one. I know there's a way to do this, but it escapes me at this time. I've got a few <a href...> tags on my screen, and I want some of them to open in the same window and some to open in a pop up, sized specifically. Here's what I've got so far: <script> $(document).ready( function (){$("a", ".newWindow").click( function(){ // there's more than just width and height, but you get the idea. var handle = window.open(this.href, 'some_target', 'width=550, height=500'); }); }); </script> I've tried this same idea with the following changes: ... $("a", "#newWindow").click(... and ... $("a", newWindow).click(... and ... $("#newWindow", "a").click(... and ... $(".newWindow", "a").click(... and etc., etc., etc. Where am I going wrong. So far in my jQuery experience, I've only had need to find elements by their class, element type, or ID. But not a combination of those. Can someone please hit me with the correct syntax? Hit me hard, so I don't forget it next time. :o) Cheers, Chris ------------------------------ _______________________________________________ jQuery mailing list [EMAIL PROTECTED]://jquery.com/discuss/ _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
-- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com
_______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/