The filter(function) works fine for me (jQuery v1.1.4) - return TRUE and the
filter is applied (ie. the element is kept); return FALSE and the element is
removed - so taking the documented example it would return "How are you?".

The same effect (using the documented example again) can be achieved by
using $('p').not(':has(ol)');

If you could post your HTML and script it would help. And what version of
jQuery you are using.


Pluthos wrote:
> 
> 
> Hi everyone,
> 
> I am new to this group. I have been trying to get filter(function) to
> work for a few days without success. My goal was to remove DOM
> elements that did not belong to a pre-arranged array. Out of
> desperation I tried the example given in the on line documentation at
> http://docs.jquery.com/Traversing/filter#fn. The example is:
> 
> $("p").filter(function(index) {
>   return $("ol", this).length == 0;
> });
> 
> with the corresponding HTML code:
> 
> <p><ol><li>Hello</li></ol></p><p>How are you?</p>
> 
> THIS DID NOT WORK!
> 
> Is it a bug in jQuery or am I doing something wrong? Could one of you
> try this same example? Thank you.
> 
> Pluthos
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/filter%28fn%29-tf4411567s15494.html#a12588144
Sent from the JQuery mailing list archive at Nabble.com.

Reply via email to