Jump to content

onclick show not showing everything


9three

Recommended Posts

Hey,

 

I have 18 DIVs im using. 12 of those DIVs are hidden (in css). When the user clicks on "view more" the link its suppose to show all the DIVs.

 

The problem is that when I click view more, it only shows 1 more DIV instead of showing the addtional 12.

 

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
     $('#clickview').click(function () {
       $('#viewmore').show();
     });
    });
</script>
<style type="text/css">
  .wrapper {
    width: 720px;
    margin: 0px;
    padding: 0px;
  }
    .window {
     float: left;
     width: 100px;
     height: 150px;
     margin: 10px 0px 0px 10px;
     padding: 5px;
     color: #ffffff;
     background: #000000;
    }
</style>
<div class="wrapper">
<?php

$i = 0;
while ($i < 18) {
  if ($i > 5)
    echo '<div style="display: none;" id="viewmore">';
  echo '<div class="window">Hello</div>';
  if ($i > 5)
    echo '</div>';
  $i++;
}
?>
</div>

<a href="#" id="clickview">View More</a>

 

Can anyone help? thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.