Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Slide Element from Left to Right Position

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 288
    Comment on it

    Hello readers,

    This is a quite simple blog that will show how to slide a div from left to right using jquery function. Here I have taken two div one is outer that have some property like it is set to at left position and add the background color to it for making it visible to all. And the another div paly a role that it will have own width, that is initially set to any width as according to your desire, main role is played by the jquery function on the click event, which make it toggle and add animation to it, the width as you have been set initially to your inner div that will fluctuate according to the width. Try this code as this will give you effect to add some basic functionality

    <html> 
    <head>
    <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
    <h3>Slide Left to Right Toggle Effect in a div</h3>
    <style>
      
        .inner-div{
            color: #fff;
            background-color:#42B574;
            padding: 20px;
            border: 5px solid green;
            border-style:dashed;
            width: 600px;
            
        }
          .outer-div{
            float:left;
            position:relative;
            background: #f0e68c;
            overflow: hidden;
        }
        .slide-toggle{
            position:absolute;
            cursor: pointer;
            background-color: #CA333E;
            border: 2px solid #4c3d00;
            color: #fff;
    
    
        }
    </style>
    </head>
    <body>
       
        <div class="outer-div">
            <div class="inner-div">This is quite simple example to show a div move from left to right using jquery function. Here i take two div one is outer that have some property like it is set to at left position and add the backgroud color to it for making it visible to all. And the another div paly a role that it will have own width, that is intially set to any width as according to your desire, main role is played by the jquery function on the click event, which make it toggle and add animation to it.
            </div>
        </div>
    
        <button type="button" class="slide-toggle">Slide me</button>
    
    </body>
    <script type="text/javascript">
        $(document).ready(function(){
            $(".slide-toggle").click(function(){
                $(".outer-div").animate({
                    width: "toggle"
                });
            });
        });
    </script>
    </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: