I have a link named 'changediv'. On the click of this link I want one div to slide out of the browser left and at the same time have a div slide left into the browser.
JQuery and  slide left
    
    
        
            Asked
            
        
        
            Active
            
        
            Viewed 1,607 times
        
    
    
        
            
                    
    
        
            
            4
            
            
        
    
    
    
        
        
            - 
                    
                        
                            
                        
                    
                    
                    
    
    
        Possible Duplicate: **[jQuery slide left and show](http://stackoverflow.com/questions/521291/jquery-slide-left-and-show)**
        – Siva Charan
                Aug 01 '12 at 04:12
    
                    
                
- 
                    
                        
                            
                        
                    
                    
                    
    
    
        At least show something that you have tried.
        – me_digvijay
                Aug 01 '12 at 04:43
    
                    
                
2 Answers
                    
                
            
            
            
            
                
                        
    
        
            
            1
            
            
        
    
    
        I think you are looking for something like;
$('#changediv').click(
function() {
    $('#div1').animate({"width": 0}, "slow");
    $('#div2').animate({"margin-left": 0}, "slow");
});
Here is the working demo
or if your body (or parent div) has a fixed width, you  may try
$('#changediv').click(
function() {
    $('#div1').animate({"width": 0}, "slow");
    $('#div2').animate({"width": 400}, "slow");
}); //I used a width of 400px for testing
Here is the working demo
Hope this helps..
        
        
            
                
                
                
                    
                    
                    
                    
                    
                
                
                
                    
                    
                        
    
    
         Alfred
    
    
        Alfred
        
            - 21,058
- 61
- 167
- 249
0For example, you can test this:
$('.changeDiv').on('click', function() {
  $('#div_one').animate({
     left: -9999
  },1000, function() {
     $('#div_two').animate({
        left: 200
     });
  });
});
        
        
            
                
                
                
                    
                    
                        
    
    
         thecodeparadox
    
    
        thecodeparadox
        
            - 86,271
- 21
- 138
- 164
            Asked
            
        
        
            Active
            
        
            Viewed 1,607 times
        
    4
            
            
        - 
                    Possible Duplicate: **[jQuery slide left and show](http://stackoverflow.com/questions/521291/jquery-slide-left-and-show)** – Siva Charan Aug 01 '12 at 04:12
- 
                    At least show something that you have tried. – me_digvijay Aug 01 '12 at 04:43
2 Answers
1
            I think you are looking for something like;
$('#changediv').click(
function() {
    $('#div1').animate({"width": 0}, "slow");
    $('#div2').animate({"margin-left": 0}, "slow");
});
Here is the working demo
or if your body (or parent div) has a fixed width, you may try
$('#changediv').click(
function() {
    $('#div1').animate({"width": 0}, "slow");
    $('#div2').animate({"width": 400}, "slow");
}); //I used a width of 400px for testing
Here is the working demo
Hope this helps..
 
    
    
        Alfred
        
- 21,058
- 61
- 167
- 249
0
            
            
        For example, you can test this:
$('.changeDiv').on('click', function() {
  $('#div_one').animate({
     left: -9999
  },1000, function() {
     $('#div_two').animate({
        left: 200
     });
  });
});
 
    
    
        thecodeparadox
        
- 86,271
- 21
- 138
- 164
