I have not found yet why this is working on jsFiddle but not in twitter but this is working on twitter :
$("img.avatar[src]").each(function() {
var img = $(this);
img.attr('src', img.attr('src').replace("_normal", "_bigger"));
});
Thus you don't remove the img
element but just replace its src
attribute value with the new one.
Also note that instead of testing the src
attribute value in the replaceWith
function you can use the [attributeName]
selector to get only img.avatar
with src
attribute defined.
I will try to investigate a little more on why your method is not working on twitter