public
Last active

jQuery Image Wrapper

  • Download Gist
jquery.image_wrapper.js
JavaScript
1 2 3 4 5 6 7 8 9 10
$(document).ready(function(){
 
$("img").load(function() {
$(this).wrap(function(){
return '<span class="image-wrap ' + $(this).attr('class') + '" style="position:relative; display:inline-block; background:url(' + $(this).attr('src') + ') no-repeat center center; width: ' + $(this).width() + 'px; height: ' + $(this).height() + 'px;" />';
});
$(this).css("opacity","0");
});
 
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.