The default value of $("span.ms-entity-resolved").attr("title")
is the title attribute of the first element matching the selector. If there are multiple matching elements in the page, you can use each method to traverse all matching elements.
Sample code for your reference:
$("span.ms-entity-resolved").each(function(){
var secondApproverLoginName = $(this).attr("title");
var processedSecondApproverEmailAddress = $(this).attr("ID");
var start = processedSecondApproverEmailAddress.indexOf(":");
var end = processedSecondApproverEmailAddress.indexOf("_Processed");
var secondApproverEmailAddress = processedSecondApproverEmailAddress.substring(start - 1, end);
console.log(secondApproverEmailAddress)
})
Test Result:
Different columns need to use different attributes in the selector to get the corresponding element.
$("div[title='peopleColumn1'] span.ms-entity-resolved")
$("div[title='peopleColumn2'] span.ms-entity-resolved")
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.