jQuery动画div里面的php echo

时间:2015-11-17 10:44:03

标签: javascript php jquery ajax

<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>

这是我的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>';
}}?>

如何调用提供回声的pagination.php,但只在点击收藏按钮时显示?

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

1 个答案:

答案 0 :(得分:1)

你的连续选择器错误,它应该是<subsystem xmlns="urn:jboss:domain:jmx:1.3"> <expose-resolved-model/> <expose-expression-model/> <remoting-connector/> </subsystem>

隐藏您的内容div:$('#cont');

然后将其显示在您的点击功能中:

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

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