JSFiddle - React, Tailwind, and code Playground
HTML
<div class="foo">
<h2>Hello</h2>
</div>
CSS
.foo {}
JavaScript
if ($('.foo').length) {
// test to see if an element with the class, .foo exists on the page.
alert('hello');
$('body').addClass('bar');
}