I have an image element looking like this:
<img class="heroStr border" id="pictureId_<?php echo $row['id']; ?>" src="images/no_img.png" title="<?php echo $row['name']; ?>" data-src="<?php echo $row['imageUrl']; ?>" />
When the data-src has finished downloading the src are switched (the "no_img" src shows a temporary image until the real one has finished loading). It works perfectly with this code:
jQuery("#element img").load(function(){
jQuery(this).attr('src', jQuery(this).data('src'));
});
What I want to do is remove the border
class from the img
when the image is loaded. I suppose I would just add jQuery(this).removeClass('border');
to the function but it doesn't work.
What is the correct way of doing this? Thanks!
— EDIT —
Added a jsfiddle you can use to try it out. What I'm trying to achieve now is to remove the border class when the data-src attribute has been loaded.