$("span.opt").on("click",function(){
if($(this).hasClass("close")) {
$(".nav,.content").animate({left:"225px"}, "slow");
$(".left-float").animate({left:"0"}, "slow");
$(this).removeClass("close");
}else{
$(".nav,.content").animate({left: '0'}, "slow");
$(".left-float").animate({left:"-225px"}, "slow");
$(this).addClass("close");
}
});
$("span.opt").trigger("click");
有上下文的代码吗?单看这个应该不会出此问题的。
查查是不是重复绑定事件了,或是绑定选择符的问题