0

コードを変更するにはどうすればよいですか。ある特定のものを何度もクリックするread moreと、slideToggle機能が毎回それを変更して、続きを読む/少なくし、コンテンツを表示/非表示read moreにすると、他のコードは残りますが、それでも、他のリンクをクリックするとread more、古いものはslideUp、新しい使用slideToggle関数はslideDownです。

私のHTML

<!-- === h1 === -->
    <h1>Lorem ipsum dolor sit amet</h1>
        <p>Ut enim ad minim veniam, quis nostrud exercitation.</p>
        <p class="more">Duis aute irure dolor in reprehenderit in voluptate.</p>
        <a class="read_more">... Read More</a>
    <!-- === h2 === -->             
    <h2>Consectetur adipisicing elit</h2>
        <p>On the other hand, we denounce with righteous.</p>
        <p class="more">Gemoralized by the charms of pleasure of the moment.</p>
        <a class="read_more">... Read More</a> 
    <!-- === h3 === -->                  
    <h3>Sed do eiusmod tempor incididunt</h3>
        <p>The wise man therefore always holds.</p>
        <p class="more">Et harum quidem rerum facilis est et expedita distinctio.</p>
        <a class="read_more">... Read More</a>

私のJquery

var rm = $(".read_more"),
    moreText = "... Read More",
    lessText = "... Read Less";

rm.click(function () {
  rm.text(moreText);

var $this = $(this);
var more = $this.text($this.text() == moreText ? lessText : moreText).prev(".more").slideToggle("normal");

$('.more').not(more).slideUp();
});
4

1 に答える 1