Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Introducing addClass method and toggle function in jquery

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 167
    Comment on it

    addClass() method adds one or many methods or class to the paragraph or the element you are using,This method will not remove the class but it adds another class by using different attributes. Users and also add toggle function to it. It will added transaction effect to the paragraph i.e hide and show effect on button click.

     

    <!DOCTYPE html>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("button").click(function(){
            $("p:first").addClass("para_changed");
            $("p:first").toggle(1000);
        });
    });
    </script>
    <style>
    .para_changed {
        font-size:40px;
        color:green;
        font-weight:700;
    }
    </style>
    </head>
    <body>
    
    <h1>Explanation of a class</h1>
    
    <p>This is a paragraph which added the property of another class.</p>
    <p>This is another paragraph which is same and can not effected from adding new class to it.</p>
    
    <button>click on me</button>
    
    </body>
    </html>

     

 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: