$(".togSubList").each(function () { var bob = $(this).find(".parent_link").text(); $(this).find(".sub-expand_collapse[aria-expanded='false']").attr("aria-label","expand " + bob); $(this).find(".sub-expand_collapse[aria-expanded='true']").attr("aria-label","close " + bob); });