[jQuery] I need syntax help, please.
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";
color:black;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:purple;
text-decoration:underline;}
pre
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
span.EmailStyle17
{mso-style-type:personal;
font-family:Arial;
color:navy;}
span.EmailStyle19
{mso-style-type:personal-reply;
font-family:Arial;
color:navy;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor=white lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>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.<o:p></o:p></span></font>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><o:p> </o:p></span></font>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt;color:windowtext'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
size=2 color=black face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
color:windowtext'> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <b><span style='font-weight:bold'>On Behalf
Of </span></b>Christopher Jordan
<b><span style='font-weight:bold'>Sent:</span></b> Friday, December 15, 2006
10:10 AM
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName w:st="on">jQuery
Discussion.</st1:PersonName>
<b><span style='font-weight:bold'>Subject:</span></b> Re: [jQuery] I need
syntax help, please.</span></font><font color=black><span style='color:windowtext'><o:p></o:p></span></font>
</div>
<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><o:p> </o:p></span></font>
<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'>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: <o:p></o:p></span></font>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"><!--[if gte mso 9]><xml>
<u1:shapedefaults u2:ext="edit" spidmax="1026"/>
</xml><![endif]--><!--[if gte mso 9]><xml>
<u1:shapelayout u3:ext="edit">
<u1:idmap u3:ext="edit" data="1"/>
</u1:shapelayout>
</xml><![endif]--></u1:SmartTagType>Wait, I’m confused…<u1:p></u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p> </u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>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.<u1:p></u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p> </u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>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.<u1:p></u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p> </u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'>-ALEX<u1:p></u1:p></span></font><o:p></o:p>
<p class=MsoNormal><font size=2 color=navy face=Arial><span style='font-size:
10.0pt;font-family:Arial;color:navy'><u1:p> </u1:p></span></font><o:p></o:p>
<div>
<div class=MsoNormal align=center style='text-align:center'><font size=3
color=black face="Times New Roman"><span style='font-size:12.0pt;color:windowtext'>
<hr size=2 width="100%" align=center tabindex=-1>
</span></font></div>
<p class=MsoNormal><b><font size=2 color=black face=Tahoma><span
style='font-size:10.0pt;font-family:Tahoma;color:windowtext;font-weight:bold'>From:</span></font></b><font
size=2 color=black face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma;
color:windowtext'> <a href="mailto:discuss-bounces@jquery.com">discuss-bounces@jquery.com</a>
[<a href="mailto:discuss-bounces@jquery.com">mailto:discuss-bounces@jquery.com</a>]
<b><span style='font-weight:bold'>On Behalf Of </span></b>Christopher Jordan
<b><span style='font-weight:bold'>Sent:</span></b> Friday, December 15, 2006
9:40 AM
<b><span style='font-weight:bold'>To:</span></b> <st1:PersonName u4:st="on"><st1:PersonName
w:st="on">jQuery Discussion.</st1:PersonName></st1:PersonName>
<b><span style='font-weight:bold'>Subject:</span></b> [jQuery] I need syntax
help, please.</span></font><o:p></o:p>
</div>
<u1:p></u1:p>
<p class=MsoNormal><font size=3 color=black face="Times New Roman"><span
style='font-size:12.0pt'><u1:p> </u1:p><o:p></o:p></span></font>
<p class=MsoNormal><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt;font-family:"Courier New"'>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</span></font><u1:p></u1:p><o:p></o:p>
<pre wrap=""><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p> </o:p></span></font></pre><pre
style='text-align:center'><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'>
<hr size=4 width="90%" align=center>
</span></font></pre><pre><font size=2 color=black face="Courier New"><span
style='font-size:10.0pt'><o:p> </o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>_______________________________________________<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'>jQuery mailing list<o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="mailto:discuss@jquery.com">discuss@jquery.com</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'><a
href="http://jquery.com/discuss/">http://jquery.com/discuss/</a><o:p></o:p></span></font></pre><pre><font
size=2 color=black face="Courier New"><span style='font-size:10.0pt'> <o:p></o:p></span></font></pre></div>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/