Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/419.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 jQuery动画数字计数器从零到锚点标记悬停时的值_Javascript_Jquery - Fatal编程技术网

Javascript jQuery动画数字计数器从零到锚点标记悬停时的值

Javascript jQuery动画数字计数器从零到锚点标记悬停时的值,javascript,jquery,Javascript,Jquery,数字 我需要一个jQuery动画数字计数器,在锚定标记部分悬停时从零到值,这可能吗? $({ Counter: 0 }).animate({ Counter: $('.Single').text() }, { duration: 1000, easing: 'swing', step: function() { $('.Single').text(Math.ceil(this.Counter)); } }); 150 像这样吗 函数startCounter

数字

我需要一个jQuery动画数字计数器,在锚定标记部分悬停时从零到值,这可能吗?

   $({ Counter: 0 }).animate({
  Counter: $('.Single').text()
}, {
  duration: 1000,
  easing: 'swing',
  step: function() {
    $('.Single').text(Math.ceil(this.Counter));
  }
});

150
像这样吗

函数startCounter(){
常量maxCounter=$('.Single')。数据('counter');
$({
柜台:0
}).制作动画({
计数器:最大计数器
}, {
持续时间:1000,
放松:"摇摆",,
步骤:函数(){
$('.Single').text(Math.ceil(this.Counter));
}
});
}
$(“#magic”).on('mouseenter',startCounter)



svg部分在哪里?您可以在锚定标记上悬停时向我显示谢谢,第二次悬停时数字不在counting@JabirSayed尝试删除行
$('#magic')。取消绑定()如果单个类的值设置为250或任何其他数字怎么办?@JabirSayed查看我的更新答案。现在,计数器最大值位于
单个
类的
数据计数器
属性内。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span class="Single">150</span>