jQuery .each() returns DOM element and not a jQuery object

The documention is not wrong but you may misunderstand what a jQuery object is.

The jQuery object is returned by the $() function. So $("span[id$='_TotalItemCost']") is one jQuery object which contains every span element selected.

Using .each() will iterate over the elements contained in the jQuery object. This is why this is a DOM node and not a jQuery object.

You did the right thing by using $(this) to use the jQuery methods on this specific element.

Leave a Comment