Код (Text): $(function(){ $('#imgUp').click(function(){ $('#imgDown').css('display','block'); var cssTop = $('#blockFoto').css('top'); var cssTop =parseInt(cssTop); cssTop = cssTop-125; $('#blockFoto').animate({'top':cssTop+"px"},300); }); $('#imgDown').click(function(){ $('#imgUp').css('display','block'); var cssTop = $('#blockFoto').css('top'); var cssTop =parseInt(cssTop); cssTop = cssTop+125; $('#blockFoto').animate({'top':cssTop+"px"},300); }); }); Код (Text): <div id="imgUp" style="margin-left:20%;height:35px;"> <img src='../lib/pimg/up.jpg' onmouseout="this.width='88'; this.height='34';this.style.marginLeft='0px';" onmouseover="this.width='98'; this.height='38';this.style.marginLeft='-5px';" > </div> <div style="height:876px;width:160px;margin-left:4px; overflow:hidden;"> <div style="position:relative;top:0;" id="blockFoto"> <div> <? $dh = scandir("".$_SERVER['DOCUMENT_ROOT']."/lib/img/"); foreach ($dh as $file) { if ($file!='.' AND $file!='..'){ echo " <div style=\"margin-left:6px; border-radius: 5px 5px 5px 5px; margin-top:10px;width:105px;height:105px;border:5px solid #c0c0c0;\" > <img src='/lib/img/$file' width=\"105\" height=\"105\" border='0' > </div>"; } } ?> </div> </div> </div> <div id="imgDown" style="margin-top:10px;margin-left:20%;border:0px solid #fff;"> <img src="../lib/pimg/down.jpg" onmouseout="this.width='88'; this.height='34';this.style.marginLeft='0px';" onmouseover="this.width='98'; this.height='38';this.style.marginLeft='-5px';"/> </div> Полоса прокрутки при нажатии на down.jpg или up.jpg крутит до бесконечности, как сделать ограничение, чтобы когда фотки кончились данная конструкция останавливалась?