jQuery check if a div has a class

Check with jQuery if it has some class e.g. class1. http://aamirshahzad.net

by Gopinath Kaliappan

HTML

<div class="container">
    <div class="row ">
        <div class="col-md-4" style="background-color: red">
          some content
        </div>
        <div class="col-md-4" style="background-color: yellow">
          catz
          <img width="100" height="100" src="https://lorempixel.com/100/100/cats/">
        </div>
        <div class="col-md-4" style="background-color: green">
          some more content
        </div>
    </div>
</div>

JavaScript

$(function () {
    if ($('.class1').hasClass('class2')) {
        alert('has class2');
    }
});