Agyan
adda
Run
Reset
Copy
jQuery Tutorial › jQuery Chaining and Callbacks › Chaining and callback
Back to tutorial
Code
Edit, then press Run or Ctrl+Enter
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <button id="go">Send message</button> <p id="status" style="display:none;padding:8px"></p> <div id="card" style="margin-top:10px;padding:14px;background:#fff3cd;width:220px">Click the card to remove it</div> <script> $(function () { $('#go').click(function () { $('#status') .stop(true, true) .text('Message sent ✓') .css({ background: '#d3f9d8', color: '#2b8a3e' }) .slideDown(300) .delay(1500) .slideUp(300); }); $('#card').click(function () { $(this).fadeOut(500, function () { $(this).remove(); alert('Card removed after the fade finished.'); }); }); }); </script>
Result