I’m trying to find an image with a ‘src’ that matches a variable. I have used ‘alert’ to make sure the variable ‘currentThumbnail’ is correct, so I think the problem is down to syntax. This is what I have at the moment:
var currentImage = $('.imageMain').attr('src');
var currentThumbnail = currentImage.substring(6);
var nextT = $('.thumbnails a img[src=currentThumbnail]');
The problem is with ‘img[src=currentThumbnail]’. What do I need to change to make this valid?
I’d be happy to add any more information if it’s unclear. Thank you!
should be
You need String concatenation, because you’re using variable
currentThumbnailwithin a string.An important commment from @ThiefMaster