I have a carousel of images that are dynamically populated. There is potential for up to 5 images, however, if there is less than 5 images I need to introduce some if statements in my code. Is it possible using jQuery to check if an img src is blank?
For example, if I have an image with class "optional" but it has no url, is there a way to detect this with jQuery?
<img class="optional" src="" />
Try this
$('.optional').each(function () {
if (this.src.length > 0) {
//if it has source
}
});