I would use the trigger method with a delay before the execution, I try this way:
$('#open-contact').delay(3000).trigger('click');
but the code runs instantly.
Do any of you could help me?
thank you very much
jQuery doc says:
The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.
So, I would rewrite this as
setTimeout(function() {
$('#open-contact').trigger('click');
}, 3000);
From jQuerys documentation about delay:
The .delay() method is best for delaying between queued jQuery effects. Because it is limited—it doesn't, for example, offer a way to cancel the delay—.delay() is not a replacement for JavaScript's native setTimeout function, which may be more appropriate for certain use cases.
In other words you should use setTimeout() instead, ie:
setTimeout(function () { $('#open-contact').trigger('click'); }, 3000);
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