I'm looping over an array and trying to find the parent html elements (tr & td) of an html comment tag containing specific text matching the current array value.
For the example below, I'm passing in the value of myField as dev_LocationID but it is always returning null. In this examle I'm trying to match the full string FieldInternalName = ' dev_LocationID ' I know the text is there. What am I doing wrong? Any help would be appreciated!
myField = 'dev_LocationID';
function fnFindThisField(myField){
var myFieldInternalName = "FieldInternalName='" +myField+ "'";
regexComment = new RegExp(/<!--\s*/myFieldInternalName\s*-->/g);
targetElement = regexComment.test($('td').html());
return targetElement;
}
Sample of html
<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>