... for (var i = 0; i < smiles.length; i++) { $(this).html($(this).html().replace(smiles[i][1],'<img src="' + webPath + '/images/smiles/' + smiles[i][0] +'.gif">')); } ...