JQuery highlighting effect before deleting ()

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 would like to highlight the actual line before the notch ( .remove() ). If I do not have a .remove() element, highlight the work.

How can I select first and then delete an item?

+7
jquery jquery-ui
source share
3 answers

You can use the effect and fadeOut callback functions to take actions when the first action completes:

 _item.effect('highlight', {}, 100, function(){ $(this).fadeOut('fast', function(){ $(this).remove(); }); }); 

It says: "highlight _item . When it is finished, disappear. When it is finished, delete it."

+16
source share

We have the ability to assign a callback to 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.

+5
source share

You need to queue .remove ()

 _item.queue( function() { $(this).remove(); }); 
0
source share

All Articles