转换 div 内的文本
我有一个包含金额的行项目表,用户可以选择或取消选择项目。我在页面上有一个元素,当选择发生更改时,会计算所选项目的总计。
这是我的函数,它对值进行求和。
function ComputeTotalPayment() {
var sum = 0;
$.each($("[id^='payment-amount-']"), function () {
//...compute sum here
});
if ($('amount-total'))
$('#amount-total').text('$' + sum.toFixed(2)); //display
}
当我更改 amount-total
(一个 div)的文本时,有没有办法让数字从旧值淡入新值?
I have a table of line items with amounts and the user can select or deselect items. I have an element on the page that when a change occurs in the selection(s), a total is computed for the selected items.
Here's what my function looks like that sums the values.
function ComputeTotalPayment() {
var sum = 0;
$.each($("[id^='payment-amount-']"), function () {
//...compute sum here
});
if ($('amount-total'))
$('#amount-total').text('
When I change the text of amount-total
(a div), is there a way to get the numbers to fade from the old value into the new value?
+ sum.toFixed(2)); //display
}
When I change the text of amount-total
(a div), is there a way to get the numbers to fade from the old value into the new value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
像这样的东西?:
Something like this?:
更改文本时,您可以先淡入淡出文本,然后更改内容,然后淡入淡出
Upon changing the text, you could first fade the text, then make the content change, then fade it back in
您可以克隆 dom 对象,将其放置在与旧对象相同的位置,然后淡出旧对象,同时淡入新对象,然后删除旧对象。
You could make a clone of the dom object, position in the same spot as old one then fade out the old while fading in the new one then delete the old one.