I'm looking at the following example of explicit iteration from http://jqfundamentals.com/chapter/jquery-basics:
$( 'li' ).each(function( index, elem ) {
// this: the current, raw DOM element
// index: the current element's index in the selection
// elem: the current, raw DOM element (same as this)
$( elem ).prepend( '<b>' + index + ': </b>' );
});
The comments refer to elem
as a raw DOM element, but then the code calls .prepend()
on elem
.
I'm just getting started with jQuery, but it's my understanding you can only call a jQuery method on a jQuery object - not on a raw DOM element. Am I misunderstanding?
This could be helpfull..