jQuery动画div里面的php回声

时间:2021-10-30 08:29:14
<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 my pagination.php, which gives some echoes output :

这是我的pagination.php,它给出了一些回声输出:

 <?
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 the pagination.php which gives echoes, but only show it when collections button is clicked?

如何调用给出回声的pagination.php,但只在点击集合按钮时显示它?

I think this is not ajax since we load the php first and hide it somewhere?

我认为这不是ajax,因为我们首先加载php并将其隐藏在某个地方?

1 个解决方案

#1


1  

Your cont selector is wrong, it should be $('#cont');

您的连续选择器是错误的,它应该是$('#cont');

Hide your content div : <div class="containerCollection" id="cont" style="display:none">

隐藏你的内容div:

Then make it appear 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 animate is strange, you should check best practices)

(另外你的双重动画很奇怪,你应该检查最佳实践)

#1


1  

Your cont selector is wrong, it should be $('#cont');

您的连续选择器是错误的,它应该是$('#cont');

Hide your content div : <div class="containerCollection" id="cont" style="display:none">

隐藏你的内容div:

Then make it appear 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 animate is strange, you should check best practices)

(另外你的双重动画很奇怪,你应该检查最佳实践)