1
I created a list that displays 6 results and below I have a "Show more" button that calls another query that displays 4 results. However, the results of this last query do not keep the CSS. It appears misaligned.
The code I have is this::
<section id="portfolio" class="portfolio">
<div class="container">
<div class="row">
<div class="col-lg-10 col-lg-offset-1 text-center">
<h2>Portfolio</h2>
<hr class="small">
<div class="row">
<?php
$query=mysqli_query($db,"select id_album, nome, foto from albuns order by id_album ASC limit 6");
while($cat=mysqli_fetch_assoc($query)){?>
<div class="col-md-6">
<div class="portfolio-item">
<p class="imgDescription"> <?php echo $cat['nome'];?> </p>
<a>
<img class="img-portfolio img-responsive" src="<?php echo $cat['foto'];?>" onClick="location.href='listagem_album.php?ida=<?php echo $cat['id_album'];?>'">
</a>
</div>
</div>
<?php } ?>
<?php
$query=mysqli_query($db,"select id_album, nome, foto from albuns order by id_album DESC limit 4");
?><div id="fotos" style="display:none"> <?php
while($cat=mysqli_fetch_assoc($query)){?>
<div class="col-md-6">
<div class="portfolio-item">
<p class="imgDescription"> <?php echo $cat['nome'];?> </p>
<a>
<img class="img-portfolio img-responsive" src="<?php echo $cat['foto'];?>" onClick="location.href='listagem_album.php?ida=<?php echo $cat['id_album'];?>'">
</a>
</div>
</div>
<?php } ?>
</div>
</div>
<!-- /.row (nested) -->
<div id="button"><a class="btn btn-dark">View More Categories</a></div>
</div>
<!-- /.col-lg-10 -->
</div>
<!-- /.row -->
</div>
<!-- /.container -->
</section>
The button code is as follows:
<script>
$("button").click(function(){
$("#fotos").fadeIn();
$("#button").hide();
});
</script>
Thank you.
First problem: your jQuery code assigning click event to button is incorrect. Instead of
$('#button')' você colocou
$('button')sem o hashtag
#` which indicates that it is an id, which means that the event does not work. About the CSS problem, you have to post your CSS to the question so someone can solve it.– Paulo Roberto Rosa