Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/redis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何自定义此脚本以在另一个脚本上显示图像?_Jquery_Html_Fadein - Fatal编程技术网

Jquery 如何自定义此脚本以在另一个脚本上显示图像?

Jquery 如何自定义此脚本以在另一个脚本上显示图像?,jquery,html,fadein,Jquery,Html,Fadein,我有一个脚本,它可以交叉淡出图像。但我有一些文本图像,我想在每张图像上显示为淡入淡出。这意味着,当第一个图像出现时,它将暂停,然后文本图像将淡入该图像,然后淡出。之后,第二个图像淡入 function slideSwitch() { var $active = $('#slideshow IMG.active'); if ( $active.length == 0 ) $active = $('#slideshow IMG:last'); // use this to pull the im

我有一个脚本,它可以交叉淡出图像。但我有一些文本图像,我想在每张图像上显示为淡入淡出。这意味着,当第一个图像出现时,它将暂停,然后文本图像将淡入该图像,然后淡出。之后,第二个图像淡入

function slideSwitch() {
var $active = $('#slideshow IMG.active');

if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

// use this to pull the images in the order they appear in the markup
var $next =  $active.next().length ? $active.next()
    : $('#slideshow IMG:first');

// uncomment the 3 lines below to pull the images in random order

// var $sibs  = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length );
// var $next  = $( $sibs[ rndNum ] );


$active.addClass('last-active');

$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1500, function() {
        $active.removeClass('active last-active');
    });
}

$(function() {
setInterval( "slideSwitch()", 5000 );

});

只需在回调中淡入文本图像即可为下一张幻灯片设置动画:

$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1500, function() {
        // Fade in/out text image here
        $active.removeClass('active last-active');
    });
}

只需在回调中淡入文本图像即可为下一张幻灯片设置动画:

$next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 1500, function() {
        // Fade in/out text image here
        $active.removeClass('active last-active');
    });
}

谢谢你的回复。我是javascript新手。你能详细说明一下吗?再次感谢。回调函数在图像出现后立即调用,因此它是淡入淡出您提到的文本图像的最佳位置。您可以使用与设置其他图像动画相同的方法或更具体的
fadeIn
fadeOut
方法。类似于
$('#myTextImage').fadeIn('slow').delay(1000).fadeOut('slow')就可以了。对不起,它不起作用。第一个图像在第二个图像开始之前不断淡出。循环仅在这两个图像(第一个图像和文本图像)之间继续进行。[$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0},1500,function(){$('slideshow IMG:middle active').fadeIn('slow').delay(1000).fadeOut('slow');$active.removeClass('active last active');});谢谢你的回复。我是javascript新手。你能详细说明一下吗?再次感谢。回调函数在图像出现后立即调用,因此它是淡入淡出你提到的文本图像的最佳位置。你可以使用与制作其他图像动画相同的方法或更具体的
fadeIn
fadeOut
方法。类似于
$(“#myTextImage”).fadeIn('slow').delay(1000)。fadeOut('slow');
的方法会起作用。抱歉,它不起作用。第一个图像在第二个图像开始之前会逐渐淡出。循环只在这两个图像(第一个图像和文本图像)之间继续进行。[$next.css({opacity:0.0}).addClass('active').animate({opacity:1.0},1500,function(){$('slideshow IMG:middle active')).fadeIn('slow').delay(1000).fadeOut('slow');$active.removeClass('active last active');});