Such a dilemma. Made a slider, everything works well except for one thing: if you click on one picture 2 times, then the big version disappears completely. I assume that prepend () does not work.
$('.laast img').each(function(){ var oldImg = $(this).attr('src'); var ext= /(\.\w{3,4}$)/; var newImg = oldImg.replace(ext,'_q$1'); var newI= $('<img src="'+newImg+'">'); $(this).click(function(){ newI.hide(); $('.big').prepend(newI); newI.fadeIn(1000); $('.big img:last').fadeOut(1000,function(){ $(this).remove(); }); }); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="laast"> <p>Заголовок заголовок</p> <img src="image/small/blue.jpg" alt=""> <img src="image/small/green.jpg" alt=""> <img src="image/small/orange.jpg" alt=""> <img src="image/small/purple.jpg" alt=""> <img src="image/small/red.jpg" alt=""> <img src="image/small/slide1.jpg" alt=""> <div class="big"> <img src="image/small/blue_q.jpg" alt="" class="q2"> </div> </div>
$('.laast > img').click(function() { ... });- IgornewIand$('.big img:last')correspond to the same DOM element. - Igor