JSFiddle - React, Tailwind, and code Playground
HTML
<span>
<input type="text" name="relation" class="IdRelation">
</span>
JavaScript
if ($('span').hasClass('IdRelation')) {
alert("ok");
}
<span>
<input type="text" name="relation" class="IdRelation">
</span>
if ($('span').hasClass('IdRelation')) {
alert("ok");
}