Example of jquery queue function usage
- 2020-05-05 10:56:59
- OfStack
This example illustrates the use of jquery queue functions. Share with you for your reference. The specific implementation method is as follows:
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="jquery-1.9.1.js"></script>
</head>
<body>
<style>
div { margin:3px; width:40px; height:40px;
position:absolute; left:0px; top:30px;
background:green; display:none; }
div.newcolor { background:blue; }
</style>
Click here...
<div></div>
<script>
$(document.body).click(function () {
$("div").show("slow");
//$("div").slideDown();
$("div").animate({left:'+=200'},2000);
$("div").queue(function () {// In the queue
$(this).addClass("newcolor");
$(this).dequeue();// Out of the queue
});
$("div").animate({left:'-=200'},2000);
$("div").queue(function () {// In the queue
$(this).removeClass("newcolor");
$(this).dequeue();// Out of the queue
});
$("div").slideUp();
});
</script>
</body>
</html>
I hope this article will be helpful for you to learn jQuery programming.