Skip to content Skip to sidebar Skip to footer

Removing Image Src Attribute

Removing the src attribute on an image tag doesn't seem to redraw the view on iOS(7) or Android (KitKat). Neither does changing the attribute to a blank value. Desktop browsers wor

Solution 1:

You could force element redraw using this kind of snippet:

$.fn.redraw = function(){
    returnthis.hide().show(0);
};

Or maybe better:

$.fn.redraw = function(){
    returnthis.each(function(){
        var zIndex = $(this).css('z-index');
        $(this).css('z-index',-1).css('z-index',zIndex);
    });
};

Then use it as e.g:

$('#imgPreview').removeAttr('src').redraw();

Post a Comment for "Removing Image Src Attribute"