变量数组在写入时复制/跳过一个项目

时间:2015-06-02 18:45:44

标签: javascript jquery

    var dates =["09/27/2014","12/19/2013","01/13/2015",""];
    var departments = ["Item1","Item2","item3",""];
    var writespeed = 400;
    $('.department_name').html(departments[fade-1]);
    $('.date_name').html(dates[fade-1]);

3 个答案:

答案 0 :(得分:0)

问题出现在以下代码行中:

$('.department_name').html(departments[fade-1]);

问题是,在你的循环中,“淡入淡出”不会增加。您可以使用fade++或将其分配给不同的变量并递增它。

答案 1 :(得分:0)

除了分配新变量外,什么都没有。

var z = 1;

然后:

z++;

答案 2 :(得分:-1)

很难从jquery中分辨出来,但我相信'淡入淡出'需要增加:

var fade = 1;
    var depart_time = 1000;
    console.log(0,fade);
    $('.shutter').removeClass('closed-shutter open-move opened-shutter close-move');
    function writeText(args) {
        var dates =["09/27/2014","04/26/2014","03/17/2015"];
        var departments = ["Item1","Item2","Item3"];
        var writespeed = 700;
        $('.write-text').each(function(){
            $('.department_name').html(departments[fade-1]);
            $('.date_name').html(dates[fade-1]);
            fade++;
            $(this).width('auto');
            var w = $(this).width();
            $(this).width(0).animate({width:w+'px'}, writespeed, function(){
                if ($(this).hasClass('patient_name')) {
                    $(this).removeClass('write-text');
                }
            });
        });
    }