It seems like a matter of course that means of filtering that are
exposed as both pseudoselectors and methods on the jQuery prototype
return the same set of elements, or at least that they generally apply
the same principle in filtering.  Examples include eq, not, first,
last, and has.  While the :parent pseduo doesn't work the same
as .parent(), most developers know what they're looking for if they're
using :parent.

The new $.fn.contains method, however, doesn't work like :contains.
Rather than searching for the text content of elements, .contains() is
just a shortcut to $(elem).has("foo").length > 0.  I'm not sure why
this is really a necessary shortcut, given that most people are plenty
used to doing something like .has().length anyway.  I tend to think,
however, that .contains () should work like :contains, for
consistency's sake.

This would have the added benefit of allowing those people who do
use :contains to write code like this:

var foo = "barbazbat";
$("div").contains(foo);

instead of
$("div:contains("+foo+")");

Anyone else have any thoughts on this?

--adam

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to