Good day! The situation is this: I pull out the pictures from the folder like this

var col = 0; for(i=1;i<22+1;i++) { document.write('<div class="swiper-slide"><div class="swiper-zoom-container"><img alt="" src="images/books/lookins/files/math/'+i+'.jpg" id="'+i+'"></div></div>'); document.getElementById(i).onload = function() { return; col++; } } 

It is necessary that a certain picture (say 2.jpg) is not pulled out. How to do? Help somebody!

  • "did not pull out" - ?? if (i != 2) { ... } - Igor
  • return; col++; - unreachable code col++; - Igor
  • Thank! And how should it look like? I just don’t think of a teapot at once ... - zfiodor
  • what should look like? What does "not pull out" mean? Imagine that nobody here has any idea what you want to do. - Igor
  • OK! It means that from a certain folder all the pictures are selected except 2.jpg. And to look, I mean the finished piece of code, because it’s very far from it, but you need to do it now. - zfiodor

1 answer 1

 var col = 0; for(i = 1; i < 22 + 1; i++) { if (i != 2) { document.write('<div class="swiper-slide"><div class="swiper-zoom-container">' + '<img alt="" src="http://placehold.it/120x120&text=image'+i+'" id="'+i+'">' + i + '</div></div>'); document.getElementById(i).onload = function() { col++; console.log("col=",col); return; } } } 
 .swiper-slide { border:2px solid black; } .swiper-zoom-container { border:2px solid red; } 

  • Thank you very much! I will try now ... - zfiodor
  • Super! Everything is working! Thank you so much! Tell me, and if, in addition to 2.jpg, you don’t have to choose a picture (say 10.jpg), but where should I register it? - zfiodor
  • Already figured out. Thanks again! - zfiodor