2012年2月3日 星期五

jquery_setTimeout_example(Jquery)

<script type="text/javascript">
    $(function(){
            var i = -1;
            var a = -1;
            $('#content #column-left .box .box-content').eq(1).attr("class", 'on1');
            $('#content #column-left .box .box-content').eq(1).attr("class", 'on2');

        //    alert($('.on2 .images div').length);
            autoShow();
            function autoShow(){   
                if(i+1<$('.on1 .images div').length){
                        i++;
                    }else{
                        i=0;
                    }
                    if(a+1<$('.on2 .images div').length){
                        a++;
                    }else{
                        a=0;
                    }

                $('.on1 .images div').eq(i).show().siblings().hide();
                $('.on1 .slidetabs a').eq(i).addClass("current").siblings().removeClass("current");
                $('.on2 .images div').eq(a).show().siblings().hide();
                $('.on2 .slidetabs a').eq(a).addClass("current").siblings().removeClass("current");
                timer = setTimeout(autoShow, 5000);
            }  
    });
</script>
-------------------------------------------------------------------------------------------------------------------------------
Other examples of jquery :
              http://www.minwt.com/?p=1138

最主要我知道了 eq() 抓取麼一個相同元素的使用方法,
不會因為每一次都 抓到第一個煩惱。

沒有留言:

張貼留言