Jquery幻灯片放映:正确的触发器?

Jquery幻灯片放映:正确的触发器?,jquery,slider,slideshow,Jquery,Slider,Slideshow,我在实现Soh Tanaka优秀的jQuery技术时遇到了一些问题。我需要将触发器锚定标记嵌套在无序列表中,这会破坏脚本(将锚定标记从列表中拉出,否则会更正问题)。我认为这取决于$selected是如何定义的,这一行: $selected = $('#ix_slideshow_nav li a.selected').next(); HTML 找到正确路径的答案: $selected = $('#ix_slideshow_nav li a.selected').parent().next().f

我在实现Soh Tanaka优秀的jQuery技术时遇到了一些问题。我需要将触发器锚定标记嵌套在无序列表中,这会破坏脚本(将锚定标记从
    列表中拉出,否则会更正问题)。我认为这取决于$selected是如何定义的,这一行:

    $selected = $('#ix_slideshow_nav li a.selected').next();
    
    HTML


    找到正确路径的答案:

    $selected = $('#ix_slideshow_nav li a.selected').parent().next().find('a'); //Move to the next nav item
    
    给我在Bendyworks.com上的朋友一个帽子提示,让他们回答这个问题

    …你不能把一个作为Matti的直接孩子,对吧--编辑HTML来修复。非常感谢。
        $(document).ready(function(){
    
        //Show the paging and activate its first link
        $("#ix_slideshow_nav a:first").addClass("selected");
    
        //Get size of the image, how many images there are, then determine the size of the image reel.
        var imageWidth = $("#ix_slideshow_window").width();
        var imageSum = $("#ix_slideshow_reel .ixss dd img").size();
        var imageReelWidth = imageWidth * imageSum;
    
        //Adjust the image reel to its new size
        $("#ix_slideshow_reel").css({'width' : imageReelWidth});
    
    
        //Paging  and Slider Function
        rotate = function(){
            var triggerID = $selected.attr("rel") -1; //Get number of times to slide
            var image_reelPosition = triggerID * imageWidth; //Determines the distance the image reel needs to slide
    
            $("#ix_slideshow_nav a").removeClass('selected'); //Remove all selected class
            $selected.addClass('selected'); //Add selected class (the $selected is declared in the rotateSwitch function)
    
            //Slider Animation
            $("#ix_slideshow_reel").animate({
                left: -image_reelPosition
            }, 500 );
    
        }; 
    
        //Rotation  and Timing Event
        rotateSwitch = function(){
            play = setInterval(function(){ //Set timer
                $selected = $('#ix_slideshow_nav li a.selected').next(); //Move to the next nav item
                if ( $selected.length === 0) { //If slideshow nav reaches the end...
                    $selected = $('#ix_slideshow_nav a:first'); //go back to first
                }
                rotate(); //Trigger the paging and slider function
            }, 2000); //Timer speed in milliseconds 
        };
    
        rotateSwitch(); //Run function on launch
    
        //On Hover
        $("#ix_slideshow_nav a").hover(function() {
            clearInterval(play); //Stop the rotation
        }, function() {
            rotateSwitch(); //Resume rotation timer
        }); 
    
        //On Click
        $("#ix_slideshow_nav a").click(function() {
            $selected = $(this); //Activate the clicked paging
            //Reset Timer
            clearInterval(play); //Stop the rotation
            rotate(); //Trigger rotation immediately
            rotateSwitch(); // Resume rotation timer
            return false; //Prevent browser jump to link anchor
        });
    
    
    });
    
    $selected = $('#ix_slideshow_nav li a.selected').parent().next().find('a'); //Move to the next nav item