I have an example where I use jQuery to get and replace titles attribute of images. ( I change title attribute for the purpose of translation). Here an example, that works, but I can not understand when I may use 'this'. Notice, in the first part I used 'jQuery(this) and in the set part I used jQuery(item) and both work. Why? What's the difference between 'this' and 'item' in this context?
https://codepen.io/capbussat/pen/wvPWRPN?editors=1111
...
var titles = [];
jQuery(".container").find("img").each(function (index, item) {
titles.push(jQuery(this).attr("title"));
console.log("get " + titles[index]);
});
console.log(titles);
titles = ["a", "b"];
jQuery(".container").find("img").each(function (index, item) {
jQuery(item).attr("title", titles[index]);
console.log("set " + titles[index]);
});
document.getElementById("One").setAttribute("title", titles[0]);
console.log(titles);
...