Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to chain multiple methods in single statement

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 235
    Comment on it

    If we want to run different methods with in single statement than we can achieve it by using jQuery chaining property . With the help of jQuery chaining property we can chain different methods with each other.

    JQuery chaining property allows us to execute more than one statements at a same time. 

     If you want to use chain methods, we have to append the method to the previous method.

    In below example we are chaining css with slideup() and slidedown() methods.

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $(".chain").css("color", "#BD6982").slideUp(1000).slideDown(1000);
        });
    });
    </script>
    </head>
    <body>
    
    <div class="chain">Lorem ipsum </div>
    
    <button style="background-color:#6EA435;border:1px solid #000
    ">animate</button>
    
    </body>
    </html>

    working demo:-https://jsfiddle.net/e9jn9amp/1/

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: