I am trying to check onclick if div have one of two different classes added to main div class and if there is no such - give back alert. Here is the example of all possible div's:
<div class="mainclass class1"></div>
<div class="mainclass class2"></div>
<div class="mainclass"></div>
If I am trying to check for class existence using JS something like,
$('.mainclass').click(function () {
var check1 = $(this).hasClass('class1');
var check2 = $(this).hasClass('class2');
if(check1 == false || check2 == false)
{
alert("Hey, you are clicking empty field!")
}
});
System will always give back alert even if I will click on first two div's. Is there any ways to make proper check of this using JS?