Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

javascript - 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);
                });
           }

question from:https://stackoverflow.com/questions/66056620/call-every-element-one-by-one

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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);
      });
    });
  });
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...