标签:
$(‘#example‘).click(function(){$("#exampleBox").toggle();})
改为
$(‘#example‘).click(function(){
if($("#exampleBox").is(":visible")){
$("#exampleBox").hide();
}else{
$("#exampleBox").show();
}
})
第二种方式
$(".btn").on("click",function(){
//通过判断按钮btn有没有active这个class名判断是否已经点击过 if($(this).hasClass("active")){ //如果有了active,假设已经点击过了 //执行你的代码 //把active去掉 $(this).removeClass("active"); }else{ //没有active,假设还没有点击过 //执行你的代码 $(this).addClass("active"); }})待更新。。。。
标签:
原文地址:http://www.cnblogs.com/ccxc1111/p/4927393.html