当您单击该区域以检查它是否具有“top-nav”时,它会工作一次,但是如何使其不断检查以便每次警报都没有工作,或者具有“top-nav”类
jsfiddle:https://jsfiddle.net/jzhang172/117mg0y1/
if(!$('.view-projects').hasClass("top-nav")){
alert('has');
}else if($('.view-projects').hasClass("top-nav")){
alert('hey');
}
$('.push').click(function(){
$('.view-projects').toggleClass('top-nav');
});
.view-projects{
height:100px;
width:100%;
background:black;
}
body,html{
margin:0;
padding:0;
}
.push{
height:200px;
width:100px;
background:blue;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="view-projects"></div>
<div class="push"></div>
米琪卡哇伊
相关分类