toggle(函数1, 函数2, 函数3.....);
用于模拟鼠标连击事件,第一次触发函数1,第二次触发函数2.。。。 循环到函数1
多用于显示隐藏操作
$(function() {
$("#panel h5.head").toggle(function(){
$(this).addClass("highlight");
$(this).next().show();
}, function() {
$(this).removeClass("highlight");
$(this).next().hide();
})
});
toggle()默认为切换元素可见状态,如果元素可见,单机后则隐藏,如果隐藏则显示,所以可以写为
$(function(){
$("#panel h5.head").toggle(function() {
$(this).next().toggle();
}, function() {
$(this).next().toggle();
})
})