Use dequeue to end a custom queue function which allows the queue to keep going using query
HTML Code:
<!DOCTYPE html> <html> <head> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <meta charset="utf-8"> <title>Use dequeue to end a custom queue function which allows the queue to keep going</title> <style> div { margin: 3px; width: 50px; position: absolute; height: 50px; left: 10px; top: 30px; background-color: #9F81F7; } div.new { background-color: #3B0B24; } </style> </head> <body> <button>Start</button> <div </div> </body> </html>
JavaScript Code :
$( "button" ).click(function() { $( "div" ) .animate({ left:"+=250px" }, 2000 ) .queue(function() { $( this ).toggleClass( "new" ).dequeue(); }) .animate({ left:"-=250px" }, 2000 ); });
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
HTML Code:
JavaScript Code :
need an explanation for this answer? contact us directly to get an explanation for this answer