jQuery cookie加倍值

时间:2017-09-21 23:32:07

标签: jquery cookies js-cookie

每次添加进度条功能运行时,它都会使cookie的值加倍,每次5秒倒计时器结束时应该加10。

任何人都可以帮助指出为什么在添加后设置的cookie值加倍。

<script>
    $(document).ready(function () {
        function startContdown() {
            var fiveSeconds = new Date().getTime() + 5000;
            $('#clock').countdown(fiveSeconds, { elapse: true })
                .on('update.countdown', function (event) {
                    if (event.elapsed) {
                        $('#clock').text("countdown ended");
                        addToProgressBar(Cookies.get("test"))
                        startContdown()
                    }
                    else {
                        var $this = $(this);
                        $this.html(event.strftime('Will refresh in <span>%S</span> seconds '))
                    }
                });
        }
        function addToProgressBar(val1) {
            cookieValue = Number(val1) + 10;
            Cookies.set("test", cookieValue);
            $('#progress1').animate({
                'width': (cookieValue)
            }, 100);

            $({ counter: 1 }).animate({ counter: cookieValue / 500 * 100 }, {
                duraton: 100,
                step: function () {
                    $('#progress1').text(Math.ceil(this.counter) + ' %');
                }
            })
        }
        Cookies.set("test", 0);
        startContdown()
    });
</script>

0 个答案:

没有答案
相关问题