jQuery creates a wrapped element - a jQuery object, so maybe this will give you some idea:
$('li').each(function (index, elem) { alert(elem === this); // true alert($(this) === $(elem)); // false alert(elem.tagName + $(elem).tagName); // LI undefined alert(typeof elem + typeof $(this));// object object alert(elem.tagName === $(this).prop('tagName')); // true });
Note that the second alert = false, so even if they refer to the same element, $ (this) and $ (elem) are NOT the same wrapped object. Note that "raw" elem has a .tagName, while a wrapped jQuery object does not.
SO for your
$(elem).prepend('<b>' + index + ':</b>');
jquery takes the wrapped element ( $(elem) ) and then adds the NEW wrapped element "b" with the index and the symbol ":" as the text of its contents
EDIT: added an example property for tagName for the jQuery object in the following example and explanation of the prefile.
Mark Schultheiss Mar 18 '13 at 15:20 2013-03-18 15:20
source share