jquery 实现切换效果,划入滑出,slideToggle
$(function() {
$("#target").click(function(){
var togglearea = $(this);
if(!togglearea.next().is(":animated")){//Used to judge the animation is implementing or not
togglearea.toggleClass("origin").next().slideToggle("slow");
}
else{
togglearea.next().slideToggle("slow", function(){togglearea.toggleClass("origin");});
}
}
return false;
});
});
$("#target").click(function(){
var togglearea = $(this);
if(!togglearea.next().is(":animated")){//Used to judge the animation is implementing or not
//This if statement is used to make the animation is more smooth, if the toggled class didn't have any css style related to marign or padding, you can just use the first if statement.
if(togglearea.attr("class")=="origin"){togglearea.toggleClass("origin").next().slideToggle("slow");
}
else{
togglearea.next().slideToggle("slow", function(){togglearea.toggleClass("origin");});
}
}
return false;
});
});