<div id="switch-button" class="switch">
<div class="switchOn"></div>
</div>
<script>
$(document).ready(function(){
//
$("body").on("click",".switch",function(e){
e.stopPropagation();
console.log(this);
var length=$(this).find(".switchOn").length;
console.log(length);
if(length>0){
$(this).toggleClass("switchOn",function(){
alert("使用回调函数,先隐藏再弹出对话框!");
})
}
})
});
//回调
</script>