Test case details

Preparation Code

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <div class="foo"></div> <script>   var found = false;   $("body").addClass("foobar"); </script>

Test cases

Test #1

if ($("body.foobar").length) {  found = true; }

Test #2

if ($("body").hasClass("foobar")) {  found = true; }

Test #3

if ($("body").is(".foobar")) {  found = true; }