I cant get this to work for all items. This code only works for the first li item. I believe the error is still in the basic jquery. Colorthief is a plugin that grabs the rgb value from image which im trying to apply to each hover.
$(window).load(function () {
$(".popup-gallery li").each(function (index) {
var $myImage = $(this).find('img');
var colorThief = new ColorThief();
//Grabs 8 swatch color palette from image and sets quality to 5 (0 =slow, 10=default/fast)
var cp = colorThief.getPalette($myImage[0], 8, 5);
//Sets background to 3rd color in the palette.
$(this).find('.hover').css('background-color', 'rgb(' + cp[2][0] + ',' + cp[2][1] + ',' + cp[2][2] + ')');
});
});