jQuery .each() function with ES6 arrow functions [duplicate]

My solution is to not use this at all, but use the variables that are passed to the callback function. The first one is the index and the second one gives you the DOM element itself.

let mediaBoxes = $('.now-thumbnail');
let titles = [];
mediaBoxes.each((index, element) => {
  let obj = {
    index: index,
    title: $(element).find('.now-thumbnail-bottomtext').text().trim(),
  };
  titles.push(obj);
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)