jQuery static menu too much code

jQuery static menu too much code

Hi, I just started with jQuery and I wanted to do a website with 4 menu buttons and after I click them only content div will change. So i did something but I have too many lines of code for this simple task. I hope somebody can explain me how to to thing more efficiently.
This is my index.html page

  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5.     <link type="text/css" rel="stylesheet" href="style.css">
  6.     <title>Rainer TestPage</title>
  7.     <script type="text/javascript" src="jquery-1.7.2.min.js"></script>
  8. <script type="text/javascript" src="script.js"></script>
  9.   </head>
  10.   <body>
  11. <div id="header">
  12. <div id="menubar">
  13. <div id="home">
  14. Home
  15. </div>
  16. <div id="images">
  17. Images
  18. </div>
  19. <div id="contact">
  20. Contact
  21. </div>
  22. <div id="other">
  23. Other
  24. </div>
  25. </div>
  26. </div>
  27. <div id="content">
  28. <div id="homecontent">
  29. Home content goes here!
  30. </div>
  31. <div id="imagescontent">
  32. Images content goes here!
  33. </div>
  34. <div id="contactcontent">
  35. Contact content goes here!
  36. </div>
  37. <div id="othercontent">
  38. Other content goes here!
  39. </div>
  40. </div>
  41. <div id="footer">
  42. </div>
  43.   </body>
  44. </html>
This is my style.css

  1. #header 
  2. {
  3. position:absolute;
  4. height:100px;
  5. left:0;
  6. top:0;
  7. width:100%;
  8. background:gold;
  9. }

  10. #footer
  11. {
  12. position:absolute;
  13. height:50px;
  14. left:0;
  15. bottom:0;
  16. width:100%;
  17. background:blue;
  18. }

  19. #content
  20. {
  21. position:absolute;
  22. top:100px;
  23. bottom:50px;
  24. left:0;
  25. width:100%;
  26. background:red;
  27. }

  28. #menubar
  29. {
  30. margin:auto;
  31. width:30%;
  32. }

  33. #home,
  34. #images,
  35. #contact,
  36. #other
  37. {
  38. text-align:center;
  39. border-style:solid;
  40. border-width:1px;
  41. float:left;
  42. font-size:20pt;
  43. margin-right:1px;
  44. margin-top:30px;
  45. width:100px;
  46. height:50px;
  47. background:lightyellow;
  48. }

And script.js

  1. $(document).ready(function(){
  2. //Hide all content but home
  3. $("#imagescontent").hide();
  4. $("#contactcontent").hide();
  5. $("#othercontent").hide();
  6. //Home tab stuff
  7. $("#home").mouseenter(function(){
  8. $("#home").css("background","lightsalmon");
  9. });
  10. $("#home").mouseleave(function(){
  11. $("#home").css("background","lightyellow");
  12. });
  13. $("#home").click(function(){
  14. $("#homecontent").show();
  15. $("#imagescontent").hide();
  16. $("#contactcontent").hide();
  17. $("#othercontent").hide();
  18. });
  19. // Images tab stuff
  20. $("#images").mouseenter(function(){
  21. $("#images").css("background","lightsalmon");
  22. });
  23. $("#images").mouseleave(function(){
  24. $("#images").css("background","lightyellow");
  25. });
  26. $("#images").click(function(){
  27. $("#homecontent").hide();
  28. $("#imagescontent").show();
  29. $("#contactcontent").hide();
  30. $("#othercontent").hide();
  31. });
  32. // Contact tab stuff
  33. $("#contact").mouseenter(function(){
  34. $("#contact").css("background","lightsalmon");
  35. });
  36. $("#contact").mouseleave(function(){
  37. $("#contact").css("background","lightyellow");
  38. });
  39. $("#contact").click(function(){
  40. $("#homecontent").hide();
  41. $("#imagescontent").hide();
  42. $("#contactcontent").show();
  43. $("#othercontent").hide();
  44. });
  45. // Other tab stuff
  46. $("#other").mouseenter(function(){
  47. $("#other").css("background","lightsalmon");
  48. });
  49. $("#other").mouseleave(function(){
  50. $("#other").css("background","lightyellow");
  51. });
  52. $("#other").click(function(){
  53. $("#homecontent").hide();
  54. $("#imagescontent").hide();
  55. $("#contactcontent").hide();
  56. $("#othercontent").show();
  57. });
  58. });

And also I have a problem with centering the button text in the middle. Right now it looks like it is vertically top bot how can I put it in the middle.
Sorry about my english, it is my second language.