【问题标题】:Show more content on click title underneath title在标题下方点击标题显示更多内容
【发布时间】:2015-07-02 18:10:06
【问题描述】:

我需要在 wordpress 中显示帖子的内容。基本上我需要在点击时显示一个 div,但只显示当前帖子。我在页面上循环显示所有帖子的标题和摘录。我只想显示点击的当前标题帖子的内容。下面的示例是我目前拥有的。

$(document).on('click', '.post-id', function() {
	$(myClass, ".post-content").show();
});
<div class="post-full">
<h2 class="post-id<?php //echo get_the_ID(); ?>"><?php the_title(); ?><div class="close">Close</div></h2>
<div class="post-excerpt"><h3><?php the_excerpt(); ?></h3></div>
<div class="post-content"><?php the_content(); ?></div>
</div>

【问题讨论】:

    标签: php jquery html wordpress click


    【解决方案1】:

    如果我理解正确

    $(document).on('click', '.post-id', function()
    {
        var content = $(this).nextAll('.post-content');
    
        if (content.is(':visible'))
        {
            content.hide();
        }
        else
        {
            $('.post-content:visible').hide();
    
            content.show();
        }
    });
    

    【讨论】:

    • 酷,是的,这有效,现在我如何关闭所有其他打开的?
    • 这似乎不起作用,我不知道这是否重要,但我在 div 上使用“显示:无”,直到点击然后显示。
    • 太棒了,我想还有一个,现在我可以在再次点击标题时关闭当前节目吗?
    • @Anthony 检查新版本
    猜你喜欢
    • 2018-03-15
    • 2021-06-13
    • 2021-06-24
    • 2020-12-31
    • 1970-01-01
    • 2018-03-09
    • 1970-01-01
    • 2022-01-25
    • 2012-10-20
    相关资源
    最近更新 更多