JSFiddle - React, Tailwind, and code Playground
HTML
<table>
<tr>
<td>
<H3><nobr>Form Label</nobr></td>
<td class="ms-formbody">
<!-- FieldName='Location ID' FieldInternalName='dev_LocationID' -->
<select name="ctl00$dev_LocationID" id="ctl00_dev_LocationID">
<option value="Please choose...">Please choose...</option>
<option selected="selected" value="1">Location 1</option>
<option selected="selected" value="1">Location 2</option>
</select>
</td>
</tr>
</table>
JavaScript
function searchComments($dom) {
var comments = [];
$dom.contents().each(function (idx, node) {
if (node.nodeType === Node.ELEMENT_NODE) {
comments = comments.concat(searchComments($(node)));
} else if (node.nodeType === Node.COMMENT_NODE) {
comments.push(node);
}
});
return comments;
}
function fnFindThisField(myField) {
var myFieldInternalName = "FieldInternalName='" + myField + "'";
var foundCommentNode = null;
searchComments($(document.body)).every(function (commentNode) {
if (commentNode.nodeValue.indexOf(myFieldInternalName) !== -1) {
foundCommentNode = commentNode;
return false;
}
return true;
});
return foundCommentNode;
}
console.log(fnFindThisField("dev_LocationID").parentNode);