jQuery deferred.promise() Method

You are Here:

jQuery deferred.promise() Method

The jQuery deferred.promise() method returns a Deferred's Promise object.

This method allows an asynchronous function to prevent other code from interfering with the progress or status of its internal request.


HTML Editor
<!DOCTYPE html> <html lang="en-US"> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style> div{ width: 100px; height: 100px; background: #f69d3c; margin-top: 10px; line-height: 6; text-align: center; } </style> </head> <body> <h1>jQuery deferred.promise() Method</h1> <button>Animate</button> <div id="point1">div1</div> <div id="point2">div2</div> <script> $(document).ready(function(){ $("button").click(function(){ myAnimation("#point1", "fast"); myAnimation("#point2", "slow"); $("#point1, #point2").promise().done(function() { alert("All animations are completed"); }); }); function myAnimation(elem, speed){ $(elem).animate({width: 150}, speed); $(elem).animate({height: 150}, speed); $(elem).animate({width: 100}, speed); $(elem).animate({height: 100}, speed); } }); </script> </body> </html>



Parameter Values

targetOptionalSpecifies an object onto which the promise methods have to be attached.


Hi Developers, we almost covered 99.5% of jQuery Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in jQuery.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author