0

在我对 CSS 进行一些修改之前!一切都很好,但现在“carouFredSel”函数不断重新加载页面(奇怪的行为)演示页面的 url 是http://demos.illucent.info/butts/index.html 我认为这是在脚本底部的某个地方但是我不知道到底是哪一个

 <script type="text/javascript">
           $(document).ready(function() {

            $('#carousel1').carouFredSel({
             align:"left",
             width: '100%',
             prev: '#prev1',
             next: '#next1',
             items  : {
             visible  : 13,
             width  : "100%"
            },
             scroll : {
              items   : 2,
              duration  : 1500,
              pauseDuration : 3500
             }

            });
            $('#carousel2').carouFredSel({
             align:"left",
             width: '100%',
             prev: '#prev2',
             next: '#next2',
             items  : {
             visible  : 13,
             width  : "100%"
            },
             scroll : {
              items   : 2,
              duration  : 1500,
              pauseDuration : 3500
             }
            });
            $('#carousel3').carouFredSel({
             align:"left",
             width: '100%',
             prev: '#prev3',
             next: '#next3',
             items  : {
             visible  : 13,
             width  : "100%"
            },
             scroll : {
              items   : 2,
              duration  : 1500,
              pauseDuration : 3500
             }
            });
           //margins
           $(".carousel img").css({"margin":"0px 0px 0px 5px"});
           var items = $('.list_switch li a').each(function () {
           $(this).click(function () {
             //remove previous class and add it to clicked tab
             items.removeClass('current');
             $(this).addClass('current');
            });
             });
             //hide all content divs and show current one
             $('.wrapper').hide().eq(items.index($(this))).show('fast');

             // resume the slide on the selected slider
             $('.carousel').eq(items.index($(this))).trigger("play");
             $('.carousel').eq(items.index($(this))).trigger("slideTo");

           // select the first tab on page load       
           items[0].click();

           });
        </script>
4

1 回答 1

0

我不认为这是因为 CSS 发生了变化。

在 $(document).ready 函数中,您正在调用集合中名为“items”的第一个项目的单击事件。

items[0].click();

您的项目集合中的第一个元素是这个超链接:

<a href="index.html">

重定向到同一页面。当页面重新加载时, $(document).ready 显然会再次运行,做同样的事情。

尝试注释掉

   items[0].click(); 

你应该会发现它不再发生。

于 2012-07-28T20:52:49.533 回答