jquery re-establish img src in .load() function
问题 I'm trying to figure out how to re-establish the img src if the image src path is invalid or no image is found. I have a dynamically created img src path that may sometimes be pointing to a directory with no actual images. In this case I need to change the src to img/missing.jpg . I have done this with no luck: $('.imgContainer').append( "<img id='pic' src='/dynamically/created/path/to/img.jpg'>" ); $('.imgContainer img#pic').load(function(){ if( $(this).width() == 0 && $(this).height() == 0