【问题标题】:wordpress showing content block with ajaxwordpress 使用 ajax 显示内容块
【发布时间】:2016-11-20 17:22:27
【问题描述】:

我有图片块,它们是 WP 不同帖子的缩略图。阻止“内容();”隐藏在 CSS 中。我需要在点击 corespond img 后显示内容。

在最后一次尝试中,我尝试用内容块显示隐藏的 div,我收到了 not matching div with contetn 和这个错误:

Uncaught TypeError: $ is not a function(…)

$(".show-more").click(function(){
                                $(document).find(".more_service:not(:visible)").slideToggle('fast',
                                    function() {
                                        if ($(document).find(".more_service:not(:visible)").length==0) {
                                            $(".show-more").css("display","none");
                                        }
                                    }
                                );
                            })
#more_service {
    display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<?php
  while ($gadget->have_posts()) : $gadget->the_post(); ?>
<div class="img-hover">
  <img class="img-responsive img-rounded show-more" id="client" 
        src="<?php echo get_the_post_thumbnail_url(); ?>"
        alt="<?php the_title(); ?>">
</div>

 <div id="more_service">
    <?php the_content(); ?>
</div>

<?php endwhile;
wp_reset_query(); ?>

请告诉我,我怎样才能正确地完成这项任务?

【问题讨论】:

    标签: javascript php jquery html wordpress


    【解决方案1】:

    你正在使用 jQuery,在它被加载之前

    在这里讨论它:https://stackoverflow.com/a/12343739/7172121

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多