我不确定这是否是我需要的“回调”,但基本上我是在尝试模拟函数的反转,例如 .hover() 效果和 .click() 效果。这可能吗. 所以基本上,如果用户再次点击链接,将发生与刚刚发生的相反的情况,即 div 关闭而不是打开。是否可以使用 .click() 执行此操作?
$(document).ready(function(){
$('.content_accrd').css({"height":"0px"});
$('.paneltop').click( function() {
$(this).css({"background-position":"0px -21px"})
.siblings().animate({"height":"100px"}, 200)
}, function() {
$(this).css({"background-position":"0px 0px"})
.siblings().animate({"height":"0px"}, 200);
})
})
最佳答案
使用.toggle()
,而不是 .click()
。
Description: Bind two or more handlers to the matched elements, to be executed on alternate clicks.
关于javascript - jQuery 切换 .click() 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7676643/