Starting to learn jQuery but i know there is a better way to....

Starting to learn jQuery but i know there is a better way to....

Hello All - 

I am pretty new to jQuery and am trying to learn about it as i develop something with it...

I have the script below and it works kinda... but i know it can be written better, because if you click on facebook it opens FB like box and then if you click twitter it opens twitter and closes facebook. But then if you click on facebook again it only shows .facebook not .facebook & .likeus

Can anyone point me in the right directions for closing the social options correctly by clicking on a different one. 



  1. <script type="text/javascript">
  2. jQuery(document).ready(function(){
  3. jQuery('.pull-me-fb').toggle(function() {
  4.    jQuery('.facebook').slideToggle('slow');
  5. jQuery('.likeus').fadeIn(3000);
  6. jQuery('.instaus').fadeOut();
  7. jQuery('.instagram').fadeOut();
  8. jQuery('.followus').fadeOut();    
  9.    jQuery('.twitter').fadeOut();
  10.    return false;
  11.  },
  12. function() {
  13.    jQuery('.facebook').slideToggle('slow');
  14. jQuery('.likeus').fadeOut('fast');
  15.    return false;
  16.  });
  17.  
  18. jQuery('.pull-me-ig').toggle(function() {
  19.    jQuery('.instagram').slideToggle('slow');
  20. jQuery('.instaus').fadeIn(3000);
  21. jQuery('.likeus').fadeOut();
  22. jQuery('.facebook').fadeOut();
  23. jQuery('.followus').fadeOut();    
  24.    jQuery('.twitter').fadeOut();
  25.    return false;
  26.  },
  27. function() {
  28.    jQuery('.instagram').slideToggle('slow');
  29. jQuery('.instaus').fadeOut('fast');
  30.    return false;
  31.  });
  32. jQuery('.pull-me-tw').toggle(function() {
  33.    jQuery('.twitter').slideToggle('slow');
  34. jQuery('.followus').fadeIn(3000);
  35. jQuery('.likeus').fadeOut();
  36. jQuery('.facebook').fadeOut();
  37. jQuery('.instaus').fadeOut();
  38. jQuery('.instagram').fadeOut();
  39.    return false;
  40.  },
  41. function() {
  42.    jQuery('.twitter').slideToggle('slow');
  43. jQuery('.followus').fadeOut('fast');
  44.    return false;
  45.  });
  46. });
  47. </script>