Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Hide div by slide effect and show another div

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.04k
    Comment on it

    This code is used to hide div by slding effect towards right to left and show another div by the same sliding effect on its place .

    1. <script src="js/jquery.min.js" language="javascript" type='text/javascript'></script>
    2. <script src="js/jquery-ui.js" language="javascript" type='text/javascript'></script>
    3. <script>
    4. $(document).ready(function () {
    5. var maxHeight = 0;
    6. $('.slidingDiv').each(function() {
    7. if($(this).height() > maxHeight) maxHeight = $(this).height();
    8. });
    9. $('#wrapper').height(maxHeight);
    10.  
    11. $('#click1').click(function () {
    12. $('#box1').hide("slide", {
    13. direction: "left"
    14. }, 1000);
    15. $('#box2').show("slide", {
    16. direction: "right"
    17. }, 1000);
    18. });
    19. $('#click2').click(function () {
    20. $('#box2').hide("slide", {
    21. direction: "right"
    22. }, 1000);
    23. $('#box1').show("slide", {
    24. direction: "left"
    25. }, 1000);
    26. });
    27. });
    28. </script>
    29. <style>
    30. #wrapper {
    31. position:relative;
    32. }
    33. #wrapper div {
    34. position:absolute;
    35. top:0;
    36. }
    37. </style>
    38. <h1>TiTle</h1>
    39.  
    40. <div id="wrapper">
    41. <div id="box1" class="slidingDiv"> <a href="#" id="click1">Click to show other div</a>
    42.  
    43. <br/>Ut accumsan dignissim lorem non posuere.Aliquam iaculis nibh ultricies sem amet.Class aptent taciti sociosqu ad posuere.</div>
    44.  
    45. <div id="box2" class="slidingDiv" style="display:none"> <a href="#" id="click2">Click to show other div</a>
    46.  
    47. <br/>Ut accumsan dignissim lorem non posuere.Aliquam iaculis nibh ultricies sem amet.Class aptent taciti sociosqu ad posuere.<br>More Line!</div>
    48. </div>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: