Javascript Jquery:使用计数器显示折扣
我有两个在HTML中列出的价格。一个是总价,另一个是折扣价(折扣价是应用折扣的总价):Javascript Jquery:使用计数器显示折扣,javascript,jquery,Javascript,Jquery,我有两个在HTML中列出的价格。一个是总价,另一个是折扣价(折扣价是应用折扣的总价): 在步骤回调中使用此方法: $('#price').text(parseFloat(this.someValue).toFixed(2)); 我会这样做: jQuery(function($) { $(document).on('click', '.trigger', function () { var originalprice = parseFloat($('#price').te
在
步骤
回调中使用此方法:
$('#price').text(parseFloat(this.someValue).toFixed(2));
我会这样做:
jQuery(function($) {
$(document).on('click', '.trigger', function () {
var originalprice = parseFloat($('#price').text()),
discount = parseFloat($('.discounted-price').text());
$({someValue: originalprice})
.animate({
someValue: discount
}, {
duration: 3000,
easing: 'swing',
step: function (now) {
$('#price').text( parseInt((now * 100),10) / 100);
}
});
});
});
$('#price').text(parseFloat(this.someValue).toFixed(2));
jQuery(function($) {
$(document).on('click', '.trigger', function () {
var originalprice = parseFloat($('#price').text()),
discount = parseFloat($('.discounted-price').text());
$({someValue: originalprice})
.animate({
someValue: discount
}, {
duration: 3000,
easing: 'swing',
step: function (now) {
$('#price').text( parseInt((now * 100),10) / 100);
}
});
});
});