我想第二個[閱讀更多]在.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);
});
});
在淡出完成後做你想做的事情..在淡出回調函數中......'... fadeToggle(1000,function({// here});' – bipen