我的第二个javaScript幻灯片正在使用第一个中的图片

时间:2014-05-25 19:24:18

标签: javascript html css slideshow

我正在做一个练习html css和javaScipt的测验,我想在每个问题上方播放幻灯片。当我进行第二次幻灯片放映时,它插入了第一张照片中的两张照片。我不确定它的问题是什么

这是第一张幻灯片中的代码:

<img id="question1" style="margin-top: 50px; margin-bottom: 50px;">
        <h1>"I'm the foot master, I got my technique down and everything.." Is said by which character?</h1>

    <script type="text/javascript">
        var imgArray2 =["images/jules.png",
                "images/vega.png",
                    "images/pink.png",
                "images/worley.png"
                            ];

        var curIndex2 = 0;
        var imgDuration2 = 4000;

        function q1slideShow() {
                document.getElementById("question1").src= imgArray2[curIndex2];
        curIndex2++;
        if(curIndex2 == imgArray2.length) { curIndex2 = 0;
            }
        setTimeout("q1slideShow()", imgDuration2);
        }
        q1slideShow();
    </script>

这是第二张幻灯片中的代码:

        <img id="question2" style="margin-top: 50px; margin-bottom: 50px;">
    <h1>Whatis the name of Quentin Tarantino's characterin" Reservoir Dogs?"</h1>
    <script type="text/javascript">
    var imgArray3 =["images/rDogs1.png",
            "images/rDogs2.png",
            "images/rDogs3.png",
            "images/rDogs4.png"
    ];

    var curIndex3 = 0;
    var imgDuration3 = 4000;

    function q2slideShow() {
                          document.getElementById("question2").src= imgArray3[curIndex3];
        curIndex3++;
        if(curIndex3 == imgArray3.length) {
        curIndex3 = 0;
            }
    setTimeout("q2slideShow()", imgDuration3);
        }
        q2slideShow();
    </script>

我不确定问题是否与ID有关,或者我是否只是在应用错误的javaScript概念。

0 个答案:

没有答案