如果单击 div.msg_head,则 .msg_row 使用 animate 向下滑动,这在我的示例中起作用。我的问题是我正在尝试编写一个函数,该函数将在向下滑动单击的第二条消息之前关闭所有消息 Pane 。
这是一个例子:
最佳答案
我了解到您在向下滑动新 Pane 之前尝试向上滑动所有其他 Pane 。这样只有一个 Pane 会保持打开状态。
很简单:不要使用切换。
var $allMail = $(".msg_head");
$allMail.click(function() {
var $this = $(this);
if( $this.hasClass('opened') ) {
$this.removeClass('opened').slideUp();
} else {
// assuming 'body' is the class of the div you want to show/hide
$allMail.removeClass('opened').find('.body').slideUp();
$this.addClass('opened').find('.body').slideDown();
}
);
希望这就是您正在寻找的。
干杯!
关于jquery - 如何从 jQuery 中的另一个函数关闭 'toggle',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7343355/