I thought it would be as simple as $('img[src=URL]')
, however, thorough testing has found this does not work 100% of the time. Thus I ended up finding your possible solution in jQuery's .filter()
function. .filter()
allows you to weed the needle out of the stack based on your own callback.
I also made use of the images .load()
event. If the image is successfully loaded into the main slideshow img
tag, it will fire a .load()
event thus allowing you to make do work
after the image has loaded. So you could do something like:
$('.slideshowimg').on('load', function(e) {
$('img.active').removeClass('active');
var src = $(this).addClass('active').prop('src');
$('img').filter(function(e) { return $(this).prop('src') == src; }).addClass('active');
});