show and hide nested divs using jquery

show and hide nested divs using jquery

I am trying to hide and sow divs, I have done it in a primitiv way, and I want to do a smart function 
the problem is that the inner divs doesn't shows
the functions name is  showdiv()

  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="utf-8">
  5.   <title>hide demo</title>
  6.   <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
  7. </head>
  8. <body>
  9. <button id="div1show">show div1</button>
  10. <button id="div2show">Show div2</button>
  11. <a href="#" onclick="showdiv('div1');">Klicka här för div1</a></br>
  12. <a href="#" onclick="showdiv('div2');">Klicka här för div2</a>

  13. <div id="contentdiv" >
  14.     <div id="div1" name="div1" class="inner" style="display:none;" background: "red">
  15.       <span>Once</span> <span>upon</span> <span>a</span>
  16.       <span>time</span> <span>there</span> <span>were</span>
  17.       <span>three</span> <span>programmers...</span>
  18.     </div>

  19.     <div id="div2" name="div2" class="inner2" style="display:none;" background: "blue">
  20.          <div id="login" class="inner2"> 
  21.              <button id="btn">btn</button>
  22.         </div>
  23.          <p>text ... text</p>
  24.     </div>
  25. </div>
  26. <script>
  27.   
  28. function showdiv(toshow){
  29.     
  30.     $("#contentdiv div").hide("fast"); //Hide all divs
  31.     //$( document.getElementById("div2")).show( "fast" );
  32.     $("#" + toshow).show("fast"); //Show one specific div

  33. }    
  34.     

  35. $( "#div2show" ).click(function() {
  36.   $( document.getElementById("div1") ).hide( "fast");
  37.   $( document.getElementById("div2")).show( "fast" );
  38. });

  39. $( "#div1show" ).click(function() {
  40.   $( document.getElementById("div2") ).hide( "fast");
  41.   $( document.getElementById("div1")).show( "fast" );
  42. });
  43. </script>
  44.  
  45. </body>
  46. </html>