[jQuery] select links not children of li

[jQuery] select links not children of li

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.5730.11" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>Then I guess I'm not understanding what a filter is
then. The API for not() says this:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>"Removes the specified Element from the set of matched
elements."</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>The API for filter() says this:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>"Removes all elements from the set of matched elements that
do not match the specified expression."</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>That seems to me like it should work.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>$('a') // select all a elements</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2>$('a').not('li a') // that are not children of an LI
tag</FONT></SPAN></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=663445222-08012007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN style="FONT-SIZE: 14px"><B><FONT
face="Century Gothic"><SPAN class=159130414-05012007><FONT face=Arial
size=2><SPAN class=159130414-05012007><FONT face=Arial
size=2>____________________________________</FONT></SPAN></FONT></SPAN></DIV>
<DIV align=left>
<DIV><SPAN class=159130414-05012007><FONT face=Arial size=2><SPAN
class=159130414-05012007></SPAN></FONT></SPAN> </DIV>Andy
Matthews<BR></FONT></B></SPAN><SPAN style="FONT-SIZE: 11px"><FONT
face="Century Gothic"><SPAN
style="FONT-SIZE: 8.5pt; FONT-FAMILY: 'Century Gothic'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes">Senior
Coldfusion Developer</SPAN><BR></FONT></SPAN><SPAN style="FONT-SIZE: 11px"><FONT
face="Century Gothic"><FONT color=#808080><IMG alt="" hspace=0
src="cid:663445222@08012007-17BF" border=0><BR></FONT>Office:  877.707.5467
x747<BR>Direct:  615.627.9747<BR>Fax:
 615.467.6249</FONT></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 11px"><FONT
face="Century Gothic">amatthews@dealerskins.com<BR><A
href="http://www.dealerskins.com/">www.dealerskins.com</A></FONT></SPAN></DIV>
<DIV><SPAN style="FONT-SIZE: 11px"><IMG
src="outbind://93-00000000C239F2861A6CF5419CB9C1C05C69065584E82000/cid:3251103308_839297"></SPAN></DIV>
<DIV> </DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <B>On Behalf Of </B>Yehuda
Katz<BR><B>Sent:</B> Monday, January 08, 2007 4:42 PM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> Re: [jQuery] select links not children of
li<BR></FONT><BR></DIV>
<DIV></DIV>And John's better alternative:<BR><BR>$.fn.notFind = function(obj)
{<BR>  if ( obj.constructor == String ) obj = $(obj);<BR>  return
jQuery.set( jQuery.grep(this, function(i) { return obj.index(i) == -1 })
);<BR>};<BR><BR>
<DIV><SPAN class=gmail_quote>On 1/8/07, <B class=gmail_sendername>Yehuda
Katz</B> <<A href="mailto:wycats@gmail.com">wycats@gmail.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Make
that<SPAN class=q><BR><BR>$.fn.notFind = function(obj) {<BR>  if(typeof
obj == "string") return $.map(this, function(i) { return $(obj).index(i) == -1
? i : null  })<BR></SPAN>  else if(obj.jquery) return $.map(this,
function(i) { return obj.index(i) == -1 ? i : null  })
<DIV><SPAN class=e id=q_11003d9e010eacae_3><BR>}<BR><BR>
<DIV><SPAN class=gmail_quote>On 1/8/07, <B class=gmail_sendername>Yehuda
Katz</B> <<A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:wycats@gmail.com" target=_blank> wycats@gmail.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">You
could do something like this:<BR><BR>$.fn.notFind = function(obj) {
<BR>  if(typeof obj == "string") return $.map(this, function(i) {
return $(obj).index(i) == -1 ? i : null  })<BR>  else
if(obj.jquery) return $.map(obj, function(i) { return obj.index(i) == -1 ? i
: null  })<BR>}<BR><BR>then you could do $("a").notFind("li
a")<BR><SPAN><BR>-- Yehuda</SPAN>
<DIV><SPAN><BR><BR><BR>
<DIV><SPAN class=gmail_quote>On 1/8/07, <B class=gmail_sendername>Yehuda
Katz</B> <<A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:wycats@gmail.com" target=_blank>wycats@gmail.com</A>>
wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">.not(n)
only works when n is a filter, like .not(".absolute") or
.not(":visible")... it can not be used to test arbitrary
expressions.<BR><SPAN><BR>-- Yehuda</SPAN>
<DIV><SPAN><BR><BR>
<DIV><SPAN class=gmail_quote>On 1/8/07, <B class=gmail_sendername>Andy
Matthews</B> <<A onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:amatthews@dealerskins.com"
target=_blank>amatthews@dealerskins.com</A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Why
doesn't this work:<BR><BR>$('a').not('li a').click( function()
{<BR>        $(this).remove();<BR>        return
false;<BR>});<BR><BR>On this code:<BR><a href="">this is a
link</a> <BR><br /><br /><BR><BR><li><a
href="">a link inside an li
tag</a></li><BR><li><a href="">and
another</a></li><BR><BR><br /><br /> <BR><a
href="">and finally another link at the bottom</a><BR><BR>It
correctly removes the bottom and top links, but it also removes the
two<BR>links found within LI tags, which from the way I read the API it
should not. <BR><BR>____________________________________<BR><BR>Andy
Matthews<BR>Senior Coldfusion
Developer<BR><BR>Office:  877.707.5467
x747<BR>Direct:  615.627.9747<BR>Fax:  615.467.6249<BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:amatthews@dealerskins.com"
target=_blank>amatthews@dealerskins.com</A><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://www.dealerskins.com"
target=_blank>www.dealerskins.com</A><BR><BR><BR>-----Original
Message-----<BR>From: <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:discuss-bounces@jquery.com"
target=_blank>discuss-bounces@jquery.com</A> [mailto: <A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:discuss-bounces@jquery.com"
target=_blank>discuss-bounces@jquery.com</A>] On<BR>Behalf Of Jörn
Zaefferer<BR>Sent: Monday, January 08, 2007 3:59 PM<BR>To: jQuery
Discussion.<BR>Subject: Re: [jQuery] select links not children of li
<BR><BR>spinnach schrieb:<BR>> ..how to select all links on a page
that are not inside a list (not<BR>> children of
'li')?..<BR>><BR>Untested:<BR>$("a").filter(function() { return
!$(this).parents().is("ul "); }) <BR><BR>Requires 1.1<BR><BR>--<BR>Jörn
Zaefferer<BR><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://bassistance.de"
target=_blank>http://bassistance.de</A><BR><BR><BR>_______________________________________________
<BR>jQuery mailing list<BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:discuss@jquery.com"
target=_blank>discuss@jquery.com</A><BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="http://jquery.com/discuss/"
target=_blank>http://jquery.com/discuss/</A><BR><BR><BR>_______________________________________________
<BR>jQuery mailing list<BR><A
onclick="return top.js.OpenExtLink(window,event,this)"
href="mailto:discuss@jquery.com" target=_blank>discuss@jquery.com
</A><BR><A onclick="return top.js.OpenExtLink(window,event,this)"
href="http://jquery.com/discuss/"
target=_blank>http://jquery.com/discuss/</A><BR></BLOCKQUOTE></DIV><BR><BR
clear=all><BR></SPAN></DIV>
<DIV><SPAN>-- <BR>Yehuda Katz<BR>Web Developer | Wycats
Designs<BR>(ph)  718.877.1325
</SPAN></DIV></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>Yehuda
Katz<BR>Web Developer | Wycats Designs<BR>(ph)  718.877.1325
</SPAN></DIV></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>Yehuda
Katz<BR>Web Developer | Wycats Designs<BR>(ph)  718.877.1325
</SPAN></DIV></BLOCKQUOTE></DIV><BR><BR clear=all><BR>-- <BR>Yehuda Katz<BR>Web
Developer | Wycats Designs<BR>(ph)  718.877.1325 </BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/