Daniel Koczuła
Daniel Koczuła

Reputation: 1034

How to delay jquery functions

I've got a function:

            (function(jQuery) {
jQuery.fn.przelicz = function() {
return this.each(function() {


     var wysokosc = jQuery(window).height() * 0.554;
     jQuery(this).find("img").height(wysokosc);
            jQuery(this).height(wysokosc);
});

};
})(jQuery);

I wish that this function will be run with 300ms delay. How to do this?

Upvotes: 0

Views: 158

Answers (2)

Rich Andrews
Rich Andrews

Reputation: 4188

An alternative using jquery api can be found here http://api.jquery.com/delay/

Upvotes: 1

Barmar
Barmar

Reputation: 781235

You can use the standard JavaScript setTimeout() function to run a function after a delay.

setTimeout(jQuery.fn.przelicz, 300);

Upvotes: 1

Related Questions