Javascript 手风琴打开切换上的所有div

Javascript 手风琴打开切换上的所有div,javascript,jquery,wordpress,Javascript,Jquery,Wordpress,当单击my toggle时,我的所有div都会展开,因为代码针对的是所有div的类。我不太了解jQuery,因此无法将其更改为只针对相关的div Javascript $(function () { // The height of the content block when it's not expanded var postadjustheight = 340; // The "more" link text var postmoreText = "Clic

当单击my toggle时,我的所有div都会展开,因为代码针对的是所有div的类。我不太了解jQuery,因此无法将其更改为只针对相关的div

Javascript

$(function () {
    // The height of the content block when it's not expanded
    var postadjustheight = 340;
    // The "more" link text
    var postmoreText = "Click to Expand Post";
    // The "less" link text
    var postlessText = "Click to Condense Post";

    // Sets the .more-block div to the specified height and hides any content that overflows
    $("body.page-template-page_blog-php #content .post .entry-content").css('height', postadjustheight).css('overflow', 'hidden');

    // The section added to the bottom of the "more-less" div
    $("body.page-template-page_blog-php .entry-content").prepend('<a href="#" class="adjust"></a>');

    $("body.page-template-page_blog-php #content .post .adjust").toggle(function () {
        $("body.page-template-page_blog-php #content .post .entry-content").css('height', 'auto').css('overflow', 'visible');
        $(this).text(postlessText);
    }, function () {
        $("body.page-template-page_blog-php #content .post .entry-content").css('height', postadjustheight).css('overflow', 'hidden');
        $(this).text(postmoreText);
    });
});
$(函数(){
//内容块未展开时的高度
var postadjustheight=340;
//“更多”链接文本
var postmoreText=“单击以展开Post”;
//“更少”链接文本
var postlessText=“单击以压缩Post”;
//将.more块div设置为指定高度并隐藏溢出的任何内容
$(“body.page-template-page#blog-php#content.post.entry content”).css('height',postadjustheight.).css('overflow','hidden');
//添加到“more-less”div底部的部分
$(“body.page-template-page_blog-php.entry content”).prepend(“”);
$(“body.page-template-page#blog-php#content.post.adjust”).toggle(函数(){
$(“body.page-template-page#blog-php#content.post.entry content”).css('height','auto').css('overflow','visible');
$(this).text(postlessText);
},函数(){
$(“body.page-template-page#blog-php#content.post.entry content”).css('height',postadjustheight.).css('overflow','hidden');
$(此).text(postmoreText);
});
});
HTML


帖子内容


不了解jQuery是学习jQuery的第一步

包括这个图书馆
您应该能够根据切换来扩展/收缩所需的特定类。

这是一个javascript/jquery问题。这显然是我的第一个问题,请提供一些HTML结构。
    <div id="content">
    <div class="post">
        <div class="entry-content"><a class="adjust" href="#">Click to Expand Post</a>
            <p>Post Contents</p>
        </div>
    </div>
    </div>