[jQuery] Adding class to parent?
<HTML >
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-16">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY >
<DIV>
<TABLE CELLSPACING="0" CELLPADDING="0" BORDER="0"><!-- Letter Heading -->
<TBODY>
<TR>
<TD><!-- Left margin -->
</TD>
<TD>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=234235115-10072006>Hi
all,</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=234235115-10072006>Given a
list of links within an html list, how do I add a class to the <li> that
an <a> sits in when clicked?</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=234235115-10072006><ul
id="Links"></SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=234235115-10072006><li><a
href="#">blah</a></li></SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=234235115-10072006></ul></SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2>$("#<SPAN
class=234235115-10072006>Links</SPAN> a").click(<BR>function()<BR>{</FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=234235115-10072006>$(this.parent()).addClass("selected");</SPAN></FONT></DIV><FONT
face="Trebuchet MS" size=2>}<BR>);</FONT>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=234235115-10072006></SPAN></FONT> </DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN class=234235115-10072006>Doesn't
seem to work as I expect. Am I using .parent() incorrectly?</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2><SPAN
class=234235115-10072006>Thanks,</SPAN></FONT></DIV>
<DIV><FONT face="Trebuchet MS" size=2></FONT> </DIV>
<DIV> </DIV>
<DIV align=left>
<TABLE align=left>
<TBODY>
<TR>
<TD vAlign=top><IMG height=33
src="http://www.in2.co.uk/images/in2-logo-small.gif" width=30></TD>
<TD width=7></TD>
<TD vAlign=top><FONT face="Trebuchet MS" size=2>
<P><B>Luc Pestille</B><BR>Web Designer </P>
<P>e: luc.pestille@in2.co.uk<BR>t: +44 (0)1628 899 700<BR>f: +44 (0)1628
899 701 </P></FONT></TD></TR></TBODY></TABLE></DIV>
<DIV> </DIV></TD>
<TD><!-- Right margin -->
</TD>
</TR><!-- Disclaimer -->
<TR>
<TD COLSPAN="3"><BR>
<DIV STYLE="FONT-SIZE: 7pt; COLOR: gray; FONT-FAMILY: verdana" ALIGN="justify">In2<BR>Thames House<BR>Mere Park<BR>Dedmere Road<BR>Marlow<BR>Bucks<BR>SL7 1PB<BR><BR>Tel 01628 899700<BR>Fax 01628 899701<BR>e: <A HREF="mailto:sales@in2.co.uk">sales@in2.co.uk</A><BR>i: <A HREF="http://www.in2.co.uk/">www.in2.co.uk</A><BR><BR><FONT COLOR="silver">This message (and any associated files) is intended only for the use of discuss@jquery.com and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not discuss@jquery.com you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from us may be monitored. Any views or opinions presented are solely those of the author Luc.Pestille@in2.co.uk and do not necessarily represent those of the company. <BR><BR></FONT>
</DIV>
</TD>
</TR>
</TBODY>
</TABLE>
</DIV></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/