我在 jquery 中有一个 .each 循环,可以淡出图像以在背景中显示它们。为每个后续图像分配增加的延迟。是否可以通过点击暂停这样的循环?
<?php
$ttlart = count($rows);
echo "var ttlart = " . $ttlart . ";";
foreach ($rows as $ro) {
$fadedur = $ro['fadedur'];
echo "fadedur = " . $fadedur . ";";
$staysonscreen = $ro['staysonscreen'];
echo "staysonscreen= " . $staysonscreen . ";";
$order = $ro['order'];
echo "order= " . $order. ";";
echo "$(\"#" . $order . "\").css(\"font-size\",fadedur);";
echo "$(\"#" . $order . "\").css(\"text-indent\",staysonscreen);";
//echo "alert(\"here\");";
}
?>
var artdelay = 0;
var playstop = 0;
var ctr = 1;
$($("#images img").get().reverse()).each(function(){
fadedur = parseInt($(this).css("font-size"));
staysonscreen = parseInt($(this).css("text-indent"));
artdelay = artdelay+staysonscreen;
if (ctr < ttlart){
$(this).delay(artdelay).fadeOut(fadedur);
artdelay = artdelay+fadedur;
$(".jp-controls").click(function(){
if(playstop == 0){
$("#images img").stop(true);
playstop = 1;
}else{ //alert(artdelay);
$("#images img").delay(artdelay).fadeOut(fadedur);
playstop = 0;}
});
ctr=ctr+1;}
});