Yes, I must admit I did not test the actual documented example - I was
heading more at the root of the problem, ie what wasn't working with
Pluthos' script that caused him to try the example in the first place!


Klaus Hartl wrote:
> 
> 
> 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
>> 
>> 
> 
> 
> This is because a <p> element cannot contain a <ol> element and the 
> filter like any other related selector simply does not match, because 
> the browser's tag soup parser closes the <p> element before the <ol>
> starts.
> 
> As of lately this problem was discussed pretty often, see the following 
> thread:
> http://groups.google.com/group/jquery-en/browse_thread/thread/e8790c05fdfd754e/9044472237a98127?lnk=gst&q=simple+list&rnum=2#9044472237a98127
> 
> And the problem explained in more detail:
> http://groups.google.com/group/jquery-en/browse_thread/thread/50fa1b33346c54d4/9d9c13f8328e8bad#9d9c13f8328e8bad
> 
> 
> --Klaus
> 
> 

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

Reply via email to