0

show more/less の次のコードはうまく機能しますが、var moreText と lessText の一部であるテキスト '-' '+' をグラフィック バージョンに置き換えたいと思います。どんな助けでも大歓迎です。

Jクエリ:

<script type="text/javascript">
$(function(){

// The height of the content block when it's not expanded
var adjustheight = 85;
// The "more" link text
var moreText = "+ Read More"; 
// The "less" link text
var lessText = "- Read Less";

// Sets the .more-block div to the specified height and hides any content that overflows
$(".more-less .more-block").css('height', adjustheight).css('overflow', 'hidden');

// The section added to the bottom of the "more-less" div

$(".more-less").append('<a href="#" class="adjust"></a>');

$("a.adjust").text(moreText);

$(".adjust").toggle(function() {
    $(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible')

        $(this).text(lessText);
}, function() {
    $(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden')
    ;

    $(this).text(moreText);     
});

});

</script>

CSS:

.more-block p {
    font-family:Tahoma, Geneva, sans-serif; 
    font-size:14px; 
    line-height:22px;
    margin-bottom:20px;
    margin-top:0px;
}



a.adjust{

display:block;
font-weight:bold;
color:#333;
text-align:left;
text-decoration:none;
margin-top:20px;
padding-top: 10px;
padding-right: 10px;
padding-bottom: 10px;
width: 150px;
}


.more-less {
width: 300px;
}

HTML:

<div class="more-less">

    <div class="more-block">
      <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>
    </div>
</div>
4

1 に答える 1

1

JQueryを使用しているようですので...

これ作って:

var moreText = "<img src='plus.gif'/> Read More"; 
// The "less" link text
var lessText = "<img src='minus.gif'/> Read Less";

次に、これを行います:

$("a.adjust").html(moreText);

$(".adjust").toggle(function() {
    $(this).parents("div:first").find(".more-block").css('height', 'auto').css('overflow', 'visible')

        $(this).html(lessText);
}, function() {
    $(this).parents("div:first").find(".more-block").css('height', adjustheight).css('overflow', 'hidden')
    ;

    $(this).html(moreText);     
});
于 2013-08-29T20:54:31.180 に答える