I have the following lines of code
$("*[class]").each(function (index, elem)
{
console.log("Element: " + elem.tagName + " " + $(elem).prop("className"));
});
What I can't understand is that what's the difference between elem
and $(elem)
.
Isn't elem
already a jJuery object? if yes then why do we need to put it again like $(elem)
in the console.log
argument to get the property className.
Why can't we directly do something like elem.prop("className")
.