I had a task of embedding a div arround some images and i came up with an simple jQuery function to do the job.
I works as intended but i would like to get som feedback on the scripting. Is it the right way to go arround speedwise etc.?
The reason i ask is because i would like to become better at writing jQuery.
jQuery.fn.addImgFrame = function($) {
$(this).each(function() {
var el = $(this);
var img_url = el.attr('src');
el.replaceWith('<div class="image-frame"><img src="' + img_url + '" alt="" /></div>');
});
}
$('img.pic').addImgFrame(jQuery);