If there are several images on the page that meet all the conditions in the script, then the title is displayed for all pictures. If there are a lot of pictures on the page, for example, about twenty or even more, and all the pictures also meet all the conditions in the script, then the title is displayed only in the first few pictures, and the rest are not displayed. Somehow it defies any logic. Why so, and how can this be eliminated?
$(document).ready(function(){ newsImg = $(".news img"); newsImg.after(function() { imgTitle = $(this).attr("title"); if (imgTitle && imgTitle != '' && $(this).width() > 500 && $(this).css('float') == 'none') return "<div class='img_title'>" + imgTitle + "</div>"; }); });