我将以下切换拼凑在一起,以显示第一段,在第一段内有一个更多的按钮作为跨度。单击更多时,会显示其他段落并且隐藏更多按钮,但是当单击更少按钮时,我需要返回更多按钮..你能帮忙吗?
<script>
$('div#introduction').each(function(){
var NODES = $(this).find('p').length;
if(NODES>0){
$(this).find('p:first').addClass('first');
$(this).find('p:last').addClass('last');
$('#introduction p.first').append(' <span class="more"><a class="toggle">More</a></span>');
$('#introduction p.last').append(' <span class="less"><a class="toggle">less</a></span>');
$('#introduction p').hide().slice(0,1).addClass('fixed').show();
$('.toggle').click(function(){
$( ".more" ).hide();
$('p:not(.toggle,.fixed)').toggle();
$(this).text(function(_, ML){
return ML === 'Less' ? 'More' : 'Less';
});
});
}
});
</script>
提前谢谢了
斯图