Search code examples
javascriptjqueryodoo-10

Call every element one by one


I have 3 paragraphs here. The problem is that they are displaying at the same time. What I wanted is they will auto show and then hide one at a time.


Scenario:
First paragraph // show then hide
Sec paragraph // next show then hide
Third paragraph // next show then hide


           if(p_name != "" && l_name != "" && t_name !="")
            {
                session.rpc('/custom/custom', 
                {
                    p_name: p_name,
                }).then(function () 
                {   
                    
                    $("p.one").addClass("show").hide(5000); 
                }); 

                
                session.rpc('/cus/cus', 
                {
                    l_name : l_name,
                }).then(function () 
                {
                    $("p.two").addClass("show").hide(5000);
                }); 

                session.rpc('/cuz/cuz', 
                {
                    t_name : t_name,
                }).then(function () 
                {
                    $("p.three").addClass("show").hide(5000);
                });
           }


Solution

  • maybe this is what you are looking for

    if (p_name != "" && l_name != "" && t_name != "") {
      session.rpc('/custom/custom', {
        p_name: p_name,
      }).then(function() {
        $("p.one").addClass("show").hide(5000);
    
        session.rpc('/cus/cus', {
          l_name: l_name,
        }).then(function() {
          $("p.two").addClass("show").hide(5000);
    
          session.rpc('/cuz/cuz', {
            t_name: t_name,
          }).then(function() {
            $("p.three").addClass("show").hide(5000);
          });
        });
      });
    }