以下代码不起作用:
$(".countdown").circularCountdown({
startDate:$(this).attr('data-start'),
endDate:$(this).attr('data-end'),
timeZone:$(this).attr("timezone")
});
下面的一个很好用,
$(".countdown").circularCountdown({
startDate:$(".countdown").attr('data-start'),
endDate:$(".countdown").attr('data-end'),
timeZone:$(".countdown").attr("timezone")
});
我不明白,因为我正在此元素上调用函数,所以$(this)是否引用“ .countdown”?有人可以帮我吗?
因为this
不参考countdown
所以一种解决方案是使用each()
$(".countdown").each(function () {
$(this).circularCountdown({
startDate: $(this).attr('data-start'),
endDate: $(this).attr('data-end'),
timeZone: $(this).attr("timezone")
});
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句