首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >caroufredsel重新加载页面

caroufredsel重新加载页面
EN

Stack Overflow用户
提问于 2012-07-29 03:54:03
回答 1查看 1.1K关注 0票数 0

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

代码语言:javascript
复制
 <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>
EN

回答 1

Stack Overflow用户

发布于 2012-07-29 04:52:50

我不认为这是因为CSS的变化。

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

代码语言:javascript
复制
items[0].click();

items集合中的第一个元素是此超链接:

代码语言:javascript
复制
<a href="index.html">

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

试着注释掉

代码语言:javascript
复制
   items[0].click(); 

你会发现它不再发生了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11704173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档