The following works as expected:
$(".foo").first().text("hi!")
...because first() returns a jQuery object.
However, if I want to work with the text() method for all matches, I need to do:
$(".foo").each( function(idx, obj) {
$(obj).text("hi!")
}
)
...because each() gives you DOM objects.
What is the design reason behind this baffling difference? How can I avoid having to build a jQuery object for each match?