如果div被隐藏或者没有隐藏,我试图根据隐藏/显示功能。我的代码如下所示:
//postInbox/outbox/savedbox show all/hide all
$('.postBoxShowAll').click(function(){
$('.postBoxContent').slideToggle('fast', function(){
if($(this).is(':hidden')){
$('.postBoxShowAll').html('Show all');
}else{
$('.postBoxShowAll').html('Hide all');
}
});
});
//
*更新*
这有效:
//postInbox/outbox/savedbox show all/hide all
$('.postBoxShowAll').click(function(){
$('.postBoxContent').slideToggle('fast', function(){
if($('.postBoxContent').is(':visible')){
$('.postBoxShowAll').html('Hide all');
}else{
$('.postBoxShowAll').html('Show all');
}
});
});
//
但由于某种原因,它不会改变文本。它滑动得很好。怎么会?
答案 0 :(得分:7)
可能会尝试这个
$('.postBoxShowAll').click(function() {
$('.postBoxContent').slideToggle('fast', function() {
if ($('.postBoxContent').is(':hidden')) {
$('.postBoxShowAll').html('Show all');
} else {
$('.postBoxShowAll').html('Hide all');
}
});
});