$("#edit li input").each(function(i){ var names = $(this).attr('name'); names = names.replace(/[^a-z]/g, '') $(this).attr('name', names+(++i)); alert($(this).attr('name')) });