Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我的Javascript计时器计数器不能与引导一起工作,请告诉我如何解决它?_Javascript_Jquery_Twitter Bootstrap_Responsive Design - Fatal编程技术网

我的Javascript计时器计数器不能与引导一起工作,请告诉我如何解决它?

我的Javascript计时器计数器不能与引导一起工作,请告诉我如何解决它?,javascript,jquery,twitter-bootstrap,responsive-design,Javascript,Jquery,Twitter Bootstrap,Responsive Design,我对bootstrap非常陌生。现在我正在做一个在线考试项目。所以我需要那个项目的时间计数器。我使用引导程序获得最佳响应布局,我使用本网站的时间计数器获得最佳结果。然而,不幸的是,我的基于java脚本的时间计数器不能正常工作。我的问题是倒计时没有加载在按钮字段中,只是“加载…”只显示没有其他计时器不显示。我希望此输出“加载…1 2 3 4 5 6 7 8 9 10继续”。所以请帮助解决它。下面我将附上我的代码,请参考它。这是我的演示代码与不工作的结果。 谢谢大家! <!DOCTYP

我对bootstrap非常陌生。现在我正在做一个在线考试项目。所以我需要那个项目的时间计数器。我使用引导程序获得最佳响应布局,我使用本网站的时间计数器获得最佳结果。然而,不幸的是,我的基于java脚本的时间计数器不能正常工作。我的问题是倒计时没有加载在按钮字段中,只是“加载…”只显示没有其他计时器不显示。我希望此输出“加载…1 2 3 4 5 6 7 8 9 10继续”。所以请帮助解决它。下面我将附上我的代码,请参考它。这是我的演示代码与不工作的结果。 谢谢大家!

    <!DOCTYPE html>
<html>
<head><title>online test</title> 
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" >
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/bootstrap-responsive.css">

</head>
<body>
    <div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
    <div class="container">
<a href="#" class="brand">responsive</a>
<div class="nav-collapse collapse pull-right">
<button type="button" id="continue" class="button red btn btn-primary">Loading...</button>
</div> 
    </div>
    </div>
    </div>
<div class="hero-unit">
<h1>Here is the head line</h1>
<p>Ever</p>
<p><a href="#" class="btn btn-primary btn-large" >get start</a></p>
</div>


<script  src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
 <script>window.jQuery || document.write('<script src="<?php echo $config['base_url']; ?>js/libs/jquery-1.7.1.min.js"><\/script>')</script>
 <script src="js/jquery.countTo.js"></script> <! get jquery.countTo.js from here http://jsfiddle.net/KzrwQ/1/ >
<script  src="js/bootstrap.js"></script>
<script>
    jQuery(document).ready(function ($) {
        $('#continue').countTo({
            interval: 1000,
            startNumber: 10,
            endNumber: 0,
            onLoop: function (self, current, loop) {
                $(self).text('Wait: ' + current);
            },
            onFinish: function (self, current, loop) {
                self.removeClass('red').addClass('green');
                $(self).html('continue').on('click', function () {
                    top.location = '<?php echo('next.html'); ?>';
                });
            }
        });
    });

    </script>
</body>
</html>

在线测试
加载。。。
这是底线
曾经

window.jQuery | | document.write(“我想现在它可以工作了

但是你仍然没有解释问题是什么,所以我猜这是预期的行为

jQuery.fn.countTo = function (options) {
    if (this.length == 0) {
        return;
    }
    // save reference to self
    var self = this;
    // merge optoins
    self.options = {};
    jQuery.extend(true, self.options, {
        interval: 1000,
        startNumber: 10,
        endNumber: 0,
        onLoop: function (self, current, loop) {
            $(self).text(current);
        },
        onStart: function (self) {},
        onFinish: function (self, current, loop) {}
    }, options);

    // init the start number
    self.current = self.options.startNumber;
    // get the direction, true is 'down', false is 'up'
    self.direction = self.options.startNumber > self.options.endNumber ? true : false;
    // the current iteration
    self.loop = 0;
    // whether is finished or not
    self.finished = false;
    // the timing function
    self.timer = function (self) {
        self.intervalId = setInterval(self._interval, self.options.interval)
    }

    self._interval = function () {
        self.options.onLoop(self, self.current, self.loop);
        // going down
        if (self.direction) {
            if (self.current > self.options.endNumber) {
                self.current--;
            } else {
                self.finished = true;
            }
            // going up
        } else {
            if (self.current < self.options.endNumber) {
                self.current++;
            } else {
                self.finished = true;
            }
        }
        // clear interval and fire onFinish when finished
        if (self.finished) {
            clearInterval(self.intervalId);
            self.options.onFinish(self, self.current, self.loop)
        }
        self.loop++;
    }

    self.start = function (self) {
        self.options.onStart(self);
        self.timer(self);
    }

    self.start(self);
}



 $('#continue').countTo({
            interval: 1000,
            startNumber: 10,
            endNumber: 0,
            onLoop: function(self, current, loop) {
                $(self).text('Wait: ' + current);
            },
            onFinish: function(self, current, loop) {
                self.removeClass('red').addClass('green');
                $(self).html('continue').on('click', function() {
                    top.location = next.html;
                });
            }
        });
jQuery.fn.countTo=函数(选项){
如果(this.length==0){
返回;
}
//保存对self的引用
var self=这个;
//合并视黄体
self.options={};
extend(true,self.options{
间隔时间:1000,
开始编号:10,
结束编号:0,
onLoop:函数(自身、当前、循环){
$(自我)。文本(当前);
},
onStart:function(self){},
onFinish:函数(self、current、loop){}
},选项);
//初始化起始编号
self.current=self.options.startNumber;
//获得方向,true为“向下”,false为“向上”
self.direction=self.options.startNumber>self.options.endNumber?真:假;
//当前迭代
self.loop=0;
//完成与否
self.finished=false;
//定时功能
self.timer=功能(self){
self.intervalId=setInterval(self.\u interval,self.options.interval)
}
self.\u间隔=函数(){
self.options.onLoop(self、self.current、self.loop);
//下降
if(自我指导){
如果(self.current>self.options.endNumber){
自电流;
}否则{
self.finished=true;
}
//上升
}否则{
if(self.current
描述问题并提供代码的JSFIDLE页。你不能只是发布代码并期望得到帮助。这就是为什么没有人评论或回答。@alkis:刚才我编辑了我的问题并添加了我的确切问题是什么?如果JSFIDLE页上有我不工作的代码,请帮助找到解决方案。@alkis:你的代码现在工作了,伙计非常感谢,几个小时前,我正在编辑一些内容并添加一些编码,但它会自动隐藏。之后,我单击了编辑按钮。它会在红线中显示我的新内容部分,对不起,朋友,我是stackoverflow的新手,只是我发现了这个错误,所以现在我更改了我的内容。我认为它会满足您的要求。T嘿,这不是我的要求(只是为了澄清)。我不是想当一个蠢货,只是想帮你。你的问题并不难,但你的问题因为一个坏问题而没有任何反应。如果你从一开始就做了所有这些事情,你会在几分钟内得到答案。在倒计时结束后,我单击“继续”按钮,什么都不会发生。如果我是,请单击“继续”inue Button它将转到next.html页面。您的时间计数器工作正常,朋友,但请为我更正一些小错误。谢谢!现在我正在更正您的.js编码中的小错误朋友。我将index.html更改为'index.html'仅此而已。现在它工作得很好。感谢您出色的编码伙计!是的,我尝试修复计数器并没有检查其他东西。不管怎样,很高兴它起作用了
jQuery.fn.countTo = function (options) {
    if (this.length == 0) {
        return;
    }
    // save reference to self
    var self = this;
    // merge optoins
    self.options = {};
    jQuery.extend(true, self.options, {
        interval: 1000,
        startNumber: 10,
        endNumber: 0,
        onLoop: function (self, current, loop) {
            $(self).text(current);
        },
        onStart: function (self) {},
        onFinish: function (self, current, loop) {}
    }, options);

    // init the start number
    self.current = self.options.startNumber;
    // get the direction, true is 'down', false is 'up'
    self.direction = self.options.startNumber > self.options.endNumber ? true : false;
    // the current iteration
    self.loop = 0;
    // whether is finished or not
    self.finished = false;
    // the timing function
    self.timer = function (self) {
        self.intervalId = setInterval(self._interval, self.options.interval)
    }

    self._interval = function () {
        self.options.onLoop(self, self.current, self.loop);
        // going down
        if (self.direction) {
            if (self.current > self.options.endNumber) {
                self.current--;
            } else {
                self.finished = true;
            }
            // going up
        } else {
            if (self.current < self.options.endNumber) {
                self.current++;
            } else {
                self.finished = true;
            }
        }
        // clear interval and fire onFinish when finished
        if (self.finished) {
            clearInterval(self.intervalId);
            self.options.onFinish(self, self.current, self.loop)
        }
        self.loop++;
    }

    self.start = function (self) {
        self.options.onStart(self);
        self.timer(self);
    }

    self.start(self);
}



 $('#continue').countTo({
            interval: 1000,
            startNumber: 10,
            endNumber: 0,
            onLoop: function(self, current, loop) {
                $(self).text('Wait: ' + current);
            },
            onFinish: function(self, current, loop) {
                self.removeClass('red').addClass('green');
                $(self).html('continue').on('click', function() {
                    top.location = next.html;
                });
            }
        });