JQuery animation div inside php echo
<li>
<a id="collection" href="collections.php">
<span class="glyphicon glyphicon-th white"> Collections</span>
</a>
</li>
<?php include "pagination.php" ?>
<script>
$("#collection").click(function(){
// i want to animate the outmost container like this, but this wont work.
var cont = $("cont");
cont.animate({height: '300px', opacity: '0.4'}, "slow");
cont.animate({width: '300px', opacity: '0.8'}, "slow");
//
});
</script>
This is mine pagination.phpthat gives some echoes:
<?
if($result) {
echo '<div class="containerCollection" id="cont">';
while($row = mysqli_fetch_array ($result)) {
echo '<div style="float:left" class="divEntry">';
echo "<div align='center' class='nameEntry'>".$row['name']."</div>";
echo '<div align="center"><img src="'.$row['image'].'" class="imageEntry"/></div>';
echo "<div align='center' class='priceEntry'>".$row['price']."</div>";
echo "<div class='descEntry'>".$row['description']."</div>";
echo '</div>';
}
echo "<div class='text-center' style='clear:both'>";
echo "<ul class='pagination'>";
echo $links;
echo '</ul>';
echo '</div>';
echo '</div>';
}}?>
How to call pagination.php, which gives echoes, but show it only when you press the collection button?
I think this is not ajax, since we first load php and hide it somewhere?
+4
1 answer
Your selector is invalid, it must be $('#cont');
Hide your content div: <div class="containerCollection" id="cont" style="display:none">
Then do this in your click function:
$("#collection").click(function(){
// i want to animate the outmost container like this, but this wont work.
var cont = $("#cont");
cont.show()
.animate({height: '300px', opacity: '0.4'}, "slow")
.animate({width: '300px', opacity: '0.8'}, "slow");
//
});
(Also your double animite is weird, you should check out best practices)
+1