JavaScript DHTML/jQuery/queue

Материал из Web эксперт
Перейти к: навигация, поиск

Queue a custom function.

   <source lang="html4strict">

<html>

 <head>
   <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
   <script type="text/javascript">
       $(document).ready(function(){
           $(document.body).click(function () {
             $("div").show("slow");
             $("div").animate({left:"+=20"},2000);
             $("div").queue(function () {
               $(this).addClass("newcolor");
               $(this).dequeue();
             });
             $("div").animate({left:"-=20"},500);
             $("div").slideUp();
           });
       });
   </script>

<style>

 div { margin:3px; width:50px; position:absolute;
       height:50px; left:10px; top:30px; 
       background-color:yellow; }
 div.red { background-color:red; }
 

</style>

 </head>
 <body>
   <body>
       Click here...
   </body>

</html>

 </source>
   
  


queue(queue): Replaces the queue of all matched element with this new queue (the array of functions).

   <source lang="html4strict">

<html>

 <head>
   <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
   <script type="text/javascript">
       $(document).ready(function(){
           $(document.body).click(function () {
             $("div").show("slow");
             $("div").animate({left:"+=20"},2000);
             $("div").queue(function () {
               $(this).addClass("newcolor");
               $(this).dequeue();
             });
             $("div").animate({left:"-=20"},500);
             $("div").slideUp();
           });
       });
   </script>

<style>

 div { margin:3px; width:50px; position:absolute;
       height:50px; left:10px; top:30px; 
       background-color:yellow; }
 div.red { background-color:red; }
 

</style>

 </head>
 <body>
   <body>
       Click here...
   </body>

</html>

 </source>