jQuery: Div elements are not showing up

Posted by Legend on Stack Overflow See other posts from Stack Overflow or by Legend
Published on 2010-05-25T00:35:32Z Indexed on 2010/05/25 0:41 UTC
Read the original article Hit count: 281

Filed under:
|
|
|
|

I am adapting the Coverflow technique to work with a div. Following is the html:

    <html> 
 <head> 
  <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> 
  <style type="text/css" media="screen"> 
   body,html {
    margin: 0;
    padding: 0;
    background: #000;
    height: 100%;
    color: #eee;
    font-family: Arial;
    font-size: 10px;
   }
   div.magnifyme {
    height: 80px;
    padding: 80px;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 8000px;
   }
   div.wrapper {
    margin: 0px;
    height: 470px;
    /*border: 2px solid #999;*/
    overflow: hidden;
    padding-left: 40px;
    right: 1px;
    width: 824px;
    position: relative;
   }

   div.container {position: relative; width: 854px; height: 480px; background: #000; margin: auto;}
   div.nav {position: absolute; top: 10px; width: 20%; height: 10%; right: 1px; }
   div.magnifyme div {
    position: absolute;
    width: 300px;
    height: 280px;
    float: left;
    margin: 5px;
    position: relative;
    border: 2px solid #999;
    background: #500;
   }
  </style> 
  <script type="text/javascript" src="jquery-1.3.2.js"></script> 
  <script type="text/javascript" src="ui.coverflow.js"></script> 

  <script type="text/javascript"> 
   $(function() {
              $("div.magnifyme").coverflow();
    $("#add").click(function() {
     location.reload();
     $(".magnifyme").append("<div id=\"div5\">hello world</div>");
     $("div.magnifyme").coverflow();
    });

   });

  </script> 
 </head> 
 <body> 
    <div class="container">
    <div class="wrapper"> 
  <div class="magnifyme"> 
   <div id="div0">This is div 0</div>  
   <div id="div1">This is div 1</div>  
   <div id="div2">This is div 2</div>  
   <div id="div3">This is div 3</div>  
   <div id="div4">This is div 4</div>  

  </div> 
    </div>
    <div class="nav">
  <button type="button" id="add">Add to Deck</button>
    </div> 
   </div>
</body> 
</html>  

The coverflow function (included as a js file in the head section) is here. When I click the button, I was expecting it to add a DIV to the already present deck. For some reason, it doesn't show the newly added DIV. I tried calling the coverflow() function after I added the new element but that didn't work either. Is there any way I can make this work?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery