The delay in each of the following?

How to do to move on to the next form after 2 seconds?

tried it before, but something is wrong

$(this).closest('.product-item').find('form.ms2_form').each(function(i){
 if ($(this).find('input[name="count"]').val() > 0) { 
//$(this).submit();
 $(this).find('.msmcd-action').delay(5000 * (i + 1)).click();
//$(this).find('.msmcd-action').trigger('click');
}
 });
March 19th 20 at 08:58
2 answers
March 19th 20 at 09:00
tried it before, but didn't work

function func(ftbn) {
ftbn.closest('.product-item').find('form.ms2_form').each(function(i){
 if (ftbn.find('input[name="count"]').val() > 0) { 
//$(this).submit();
ftbn.find('.msmcd-action').trigger('click');
}
});
}
 setTimeout(func($(this)), 1000);
- Bernadette_Rueck commented on March 19th 20 at 09:03
March 19th 20 at 09:02
Here is the solution
$('.product-item .cart-btn').click(function(){
 $(this).closest('.product-item').find('form.ms2_form').each(function(i, elem){
setTimeout(function(){
 if ($(elem).find('input[name="count"]').val() > 0) { 
//$(this).submit();
$(elem).find('.msmcd-action').click();
//$(this).find('.msmcd-action').trigger('click');
}
 }, 1000 * i);

});
 });

Find more questions by tags jQueryJavaScript