我正在使用几个插件来使用 JavaScript 制作进度条动画。
我在 HTML 中设置每个数据值以避免每次都在 JavaScript 中定义它。
<div class="progress-circle" data-value="0.65">
我想获取数据值以进行动画处理并每次都停在该值处,但我目前拥有的代码将所有这些值都停在第一个 div 值处。
var el = $('.progress-circle'),
inited = false;
el.appear({ force_process: true });
el.on('appear', function() {
if (!inited) {
el.circleProgress({ value: el.attr('data-value') });
inited = true;
}
});
$('.progress-circle').circleProgress({
size: 80,
startAngle: -Math.PI / 4 * 2,
lineCap: "round",
fill: { color: "#64B46E" }
}).on('circle-animation-progress', function(event, progress, stepValue) {
$(this).find('.inner').text(String(stepValue.toFixed(2)).substr(2)+ '%');
});
我怎样才能让它使用每个 div 唯一的数据值属性?
最佳答案
$('your-div').each(function() {
//do something with $(this).data('value');
//other way to get is $(this).attr('data-value');
});
关于javascript - 获取每个单独的 div 的数据值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33463284/