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

Reply via email to