I'm trying to get this to point to each img inside a function inside an object method, like so
var responsiveImageSwap = (function(){
return {
init : function(){
$.each('img', function(){
var width = $(window).width(),
_this = this,
alert(_this.attr('src'))
})
}
}
})();
responsiveImageSwap.init();
But it is referencing the object and not the img, how do I reference the image?
$('img').each(…? Also, you don't want to compute the viewport width inside a loop.