Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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
这个jQuery代码中的$({counter:0})是什么?什么类型的选择器?_Jquery_Html_Css - Fatal编程技术网

这个jQuery代码中的$({counter:0})是什么?什么类型的选择器?

这个jQuery代码中的$({counter:0})是什么?什么类型的选择器?,jquery,html,css,Jquery,Html,Css,我有这个动画计数器,它工作得很好。但是我想知道这个选择器的类型以及它在代码中的作用。 它不是选择器。它将一个对象放入jQuery对象中,并使用库中的一个怪癖来使用animate()方法每秒递增计数器属性值,并将其设置为文本().count元素计数器的从每个.count元素的数据计数属性中获取其值。它不是选择器。它将一个对象放入jQuery对象中,并使用库中的一个怪癖来使用animate()方法每秒递增计数器属性值,并将其设置为文本().count元素计数器的从每个.count元素的数据计数属性

我有这个动画计数器,它工作得很好。但是我想知道这个选择器的类型以及它在代码中的作用。


它不是选择器。它将一个对象放入jQuery对象中,并使用库中的一个怪癖来使用
animate()
方法每秒递增
计数器
属性值,并将其设置为
文本()
.count
元素计数器的
从每个
.count
元素的
数据计数
属性中获取其值。它不是选择器。它将一个对象放入jQuery对象中,并使用库中的一个怪癖来使用
animate()
方法每秒递增
计数器
属性值,并将其设置为
文本()
.count
元素计数器的
从每个
.count
元素的
数据计数
属性中获取其值。
$(window).scroll(function () {
    var oTop = $(".counter").offset().top;
    if ($(window).scrollTop() > oTop) {
        $(".count").each(function () {
            var $this = $(this);
            var val = $(this).attr("data-count");
            $({ counter: 0 }).animate({ counter: val }, {
                duration: 1000,
                easing: 'swing',
                step: function () {
                    $this.text(Math.ceil(this.counter));
                }
            });
       });
    }
});