In this function,
template.find('.userPhoto img').error(function () {
$(this)[0].src = '/images/default.png';
}).attr('src', image);
I was expecting $(this) to refer to an individual element, but it’s not; instead, it’s referring to a wrapped set… can you spot why?
Thanks!
Because someone didn’t know any better.
In this context if you want the original DOM element, just use
thisOn the other hand, if you wish to call jQuery methods on that element, use
$(this).Since all you’re doing is setting a property of a DOM element, you should use the former: