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
https://forums.phpfreaks.com/topic/175295-onclick-show-not-showing-everything/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.