This should do the job: $("#someid").each(function() { $(this).text($(this).attr("alt")); });
It is longer and more unreadable than your original code $("#someId").text($("#someId").attr("alt")); but you do get rid of redundancy = you do not have to write the same selector twice, which is generally bad in programming... for a simple selector like #someid, you may write it your way, but for a complex selector, writing it twice is a bad idea..