0

我想重现大量点击功能,而无需将它们一直复制并粘贴到页面下方,然后更改单个数字。我的问题是我无法在我的 for 循环中更改 ID。

这是我的脚本:

for (var i=0;i<$('.slide').length;i++) {
            $step = $('#step'+i);
            $step.on('click', slideTo);
            function slideTo(event){
                $(this).off('click');
                $active = $('.current');
                if (!$active.is('#slide'+i)) {
                    $active.animate({
                        left: '-1024px'
                    }, 500, function() {
                        $(this).removeClass('current');
                    });
                    $('#slide'+i).animate({
                        left: '0'
                    }, 500, function() {
                        $(this).addClass('current');
                        $step.on('click', slideTo);
                    }).addClass('current');
                };
            };
        }

有很多 HTML,但现在这里有一点:

<div id="slider" class="article">
            <div id="slideHolder">
                <!-- Step 1 -->  
                <div class="walkthrough firstClass current">
                    <div class="step">
                        <h4>STEP 1: Go to the DRMA Service Center.</h4><p>From the RII Homepage <a href="http://r2.nrc.gov" target="_blank" title="">(r2.nrc.gov,)</a> Look under where it says Quicklinks. The second link from the top of the list is the link to the DRMA Service Center. You can click there or click the link below the image to the right. >>></p>
                    </div>
                    <div class="stepImg">
                        <img src="img/step1.jpg" alt="" />
                        <a href="" title="">Think you got it? Exit to the DRMA Service Center >>></a>
                    </div>
                    <div class="clr"></div>
                </div>
    <!-- Step 2 -->         
                <div class="walkthrough">
                    <div class="step">
                        <h4>STEP 2: LOGIN.</h4><p>Here you want to log in just as you would to your Region II workstation.<br /><br />Username: Your LAN ID<br />Password: Your regular NRC Password</p>
                    </div>
                    <div class="stepImg">
                        <img src="img/step2.jpg" alt="" />
                        <a href="" title="">Think you got it? Exit to the DRMA Service Center >>></a>
                    </div>
                    <div class="clr"></div>
                </div>
</div>
</div>
        <div id="sliderControls">
            <div class="slide" id="step1">Step 1</div>
            <div class="slide" id="step2">Step 2</div>
</div>

如果您需要我添加任何内容,请询问,谢谢。

4

0 回答 0