我希望第二个 [阅读更多] 在.content
淡出后出现。jsfiddle
HTML
<div>
<span class="heading">This is the beginning of the sentence. </span>
<span class="content">This is the end of the sentence. </span>
</div>
CSS
.heading {
cursor: pointer;
}
JS
$(document).ready(function () {
$('.content').after('<a href="#" class="toggle-link">[Read More]</a>');
$(".content").hide();
$('.toggle-link').click(function (e) {
e.preventDefault();
var $link = $(this);
if ($link.data('expanded') == true) {
$link.data('expanded', false);
$link.text('[Read More]');
} else {
$link.data('expanded', true);
$link.text('[Close]');
}
$link.prev(".content").fadeToggle(1000);
});
});