// hard way function imgFix(e){ this.onerror=null; var src = $(e).attr('src'); src = imgDir + src ; e.src = src; } // easy way