Slide 2 divs simultaneously from right and left on click

Slide 2 divs simultaneously from right and left on click

Sir, below is my code that i have tried :

  1. <html lang="en">
  2. <head>
  3. <meta charset="utf-8">
  4. <title>slide demo</title>
  5. <style>
  6. .leftpanel1 {
  7. width: 300px;
  8. height: 100px;
  9. background: #ccc;
  10. position:absolute;
  11. float:left;
  12. z-index:100;
  13. top:0;
  14. background:red;}
  15. .rightpanel1 {
  16. width: 695px;
  17. height: 100px;
  18. background: #ccc;
  19. position:absolute;
  20. float:right;z-index:100;top:0;background:red;right:0;}
  21. .leftpanel2 {
  22. width: 300px;
  23. height: 100px;
  24. background: #ccc;
  25. position:absolute;
  26. float:left;
  27. z-index:10;top:0;background:green;}
  28. .rightpanel2 {
  29. width: 695px;
  30. height: 100px;
  31. background: #ccc;
  32. position:absolute;
  33. float:right;z-index:10;top:0;background:green;right:0;}
  34. .leftpanel3 {
  35. width: 300px;
  36. height: 100px;
  37. background: #ccc;
  38. position:absolute;
  39. float:left;
  40. z-index:1;top:0;background:#ececec;}
  41. .rightpanel3 {
  42. width: 695px;
  43. height: 100px;
  44. background: #ccc;
  45. position:absolute;
  46. float:right;z-index:1;top:0;background:#ececec;right:0;}
  47. #container{position:absolute;margin:0 auto; width:1000px;height:300px;border:solid 1px red;left:0;right:0;bottom:0;top:100px;}
  48. </style>
  49. <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
  50. <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
  51. </head>
  52. <body>
  53. <a href="#" id="tog1">switch 1,2</a>
  54. <a href="#" id="tog2">switch 3,4</a>
  55. <a href="#" id="tog3">switch 4,5</a>
  56. <div id="container">
  57.  <div id="toggle1" class="leftpanel1">for switch 1</div><div id="toggle2" class="rightpanel1">for switch 2</div>
  58.  <div id="toggle3" class="leftpanel2">for switch 2</div><div id="toggle4" class="rightpanel2">for switch 3</div>
  59.  <div id="toggle5" class="leftpanel3">for switch 3</div><div id="toggle6" class="rightpanel3">for switch 4</div>
  60. </div>
  61. <script>
  62.  $(window).load(function(){
  63.   $().ready = function() {
  64.   $("#tog1").click(function() {
  65. $( "#toggle1" ).toggle("slide", { direction: "left" });
  66. $( "#toggle2" ).toggle("slide", { direction: "right" });
  67. });
  68. $("#tog2").click(function() {
  69. $( "#toggle3" ).toggle("slide", { direction: "left" });
  70. $( "#toggle4" ).toggle("slide", { direction: "right" });
  71. });
  72. $("#tog3").click(function() {
  73. $( "#toggle5" ).toggle("slide", { direction: "left" });
  74. $( "#toggle6" ).toggle("slide", { direction: "right" });
  75. });
  76. }();
  77. });
  78. </script>
  79. </body>
  80. </html>

sir in an above code i have made 3 switches as tog1, tog2, tog3. Each switches would have 2 corresponding divs to slide in and out.

I want by default only tog1 should active and it's 2 divs should slide in. Then when i click on second switch then first switch get inactive and it's divs get slide out and simultaneously switch2 get active and it's divs get slide in. same as with switch 3.

main thing is that once the switch get inactive and it's 2 divs get slide out they should not appear until it's switch being clicked.

Please suggest me something about this.... hope you should do some needful.