Then I guess I'm not understanding what a filter is then. The API for not()
says this:
"Removes the specified Element from the set of matched elements."
The API for filter() says this:
"Removes all elements from the set of matched elements that do not match the
specified expression."
That seems to me like it should work.
$('a') // select all a elements
$('a').not('li a') // that are not children of an LI tag
____________________________________
Andy Matthews
Senior Coldfusion DeveloperOffice: 877.707.5467 x747 Direct: 615.627.9747 Fax: 615.467.6249 [EMAIL PROTECTED] www.dealerskins.com <http://www.dealerskins.com/> <outbind://93-00000000C239F2861A6CF5419CB9C1C05C69065584E82000/cid:325110330 8_839297> _____ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yehuda Katz Sent: Monday, January 08, 2007 4:42 PM To: jQuery Discussion. Subject: Re: [jQuery] select links not children of li And John's better alternative: $.fn.notFind = function(obj) { if ( obj.constructor == String ) obj = $(obj); return jQuery.set( jQuery.grep(this, function(i) { return obj.index(i) == -1 }) ); }; On 1/8/07, Yehuda Katz <[EMAIL PROTECTED]> wrote: Make that $.fn.notFind = function(obj) { if(typeof obj == "string") return $.map(this, function(i) { return $(obj).index(i) == -1 ? i : null }) else if(obj.jquery) return $.map(this, function(i) { return obj.index(i) == -1 ? i : null }) } On 1/8/07, Yehuda Katz < [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: You could do something like this: $.fn.notFind = function(obj) { if(typeof obj == "string") return $.map(this, function(i) { return $(obj).index(i) == -1 ? i : null }) else if(obj.jquery) return $.map(obj, function(i) { return obj.index(i) == -1 ? i : null }) } then you could do $("a").notFind("li a") -- Yehuda On 1/8/07, Yehuda Katz <[EMAIL PROTECTED]> wrote: .not(n) only works when n is a filter, like .not(".absolute") or .not(":visible")... it can not be used to test arbitrary expressions. -- Yehuda On 1/8/07, Andy Matthews <[EMAIL PROTECTED]> wrote: Why doesn't this work: $('a').not('li a').click( function() { $(this).remove(); return false; }); On this code: <a href="">this is a link</a> <br /><br /> <li><a href="">a link inside an li tag</a></li> <li><a href="">and another</a></li> <br /><br /> <a href="">and finally another link at the bottom</a> It correctly removes the bottom and top links, but it also removes the two links found within LI tags, which from the way I read the API it should not. ____________________________________ Andy Matthews Senior Coldfusion Developer Office: 877.707.5467 x747 Direct: 615.627.9747 Fax: 615.467.6249 [EMAIL PROTECTED] www.dealerskins.com -----Original Message----- From: [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] On Behalf Of Jörn Zaefferer Sent: Monday, January 08, 2007 3:59 PM To: jQuery Discussion. Subject: Re: [jQuery] select links not children of li spinnach schrieb: > ..how to select all links on a page that are not inside a list (not > children of 'li')?.. > Untested: $("a").filter(function() { return !$(this).parents().is("ul "); }) Requires 1.1 -- Jörn Zaefferer http://bassistance.de _______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/ _______________________________________________ jQuery mailing list [email protected] <mailto:[email protected]> http://jquery.com/discuss/ -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325
att118dd.bmp
Description: Windows bitmap
_______________________________________________ jQuery mailing list [email protected] http://jquery.com/discuss/
