Reputation: 16532
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('$' + 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?
Upvotes: 1
Views: 517
Reputation: 35256
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.
Upvotes: 0
Reputation: 1719
Something like this?:
$("#amount-total").fadeOut(function(){ $(this).text("test").fadeIn(); })
Upvotes: 3
Reputation: 11210
Upon changing the text, you could first fade the text, then make the content change, then fade it back in
Upvotes: 1