Consider the following snippet:
$('.remove_item').click(function(e) {
var _item = $(this).closest('.cart_item');
if(confirm('Biztosan törölhetem a terméket a kosárból?')) {
_item.effect('highlight', {}, 100).stop().fadeOut('fast');
_item.remove();
...
I'd like to highlight the actual row before trashing (.remove()
) it. If i don't .remove()
the item, highlight working.
How can i highlight first, then remove element?
You can use the callback functionality of effect
and fadeOut
to do actions when the first action has finished:
_item.effect('highlight', {}, 100, function(){
$(this).fadeOut('fast', function(){
$(this).remove();
});
});
This says "highlight _item
. When this is finished, fade it out. When this is finished, remove it."
Yo ushould be able to assign a callback on the fadeOut:
$('.remove_item').click(function(){
if(confirm('Biztosan törölhetem a terméket a kosárból?'))
{
$(this).closest('.cart_item').fadeOut(500, function() { $(this).remove(); });
}
});
hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With