I have a ID generated from jQuery using two different fields. Like I have a Fieldname, FieldCounter which is passed from backend. My Id is declared as attribute in jQuery as
htmlInputText.attr({
'name': fieldNode.FieldName + fieldCounter,
'id': fieldNode.FieldName + fieldCounter
});
This Id changes based on the fieldname and field Counter. I need to target a Id which has FieldName as "EMP" and FieldCounter as "_BestPhone". The output Id is "EMP_BestPhone". When I try to target it by using JQuery as
$('#EMP_BestPhone').css('background', 'red');
It doesn't do anything. Anyone know how to do that.
I tried
$('#EMP_BestPhone').css('background', 'red');
$(htmlInputText).find('#EMP_BestPhone').css('background', 'red');
where htmlInputText contains the whole input tag with this Id like:
htmlInputText.attr({
'name': fieldNode.FieldName + fieldCounter,
'id': fieldNode.FieldName + fieldCounter
});
$('#EMP_BestPhone').css('background', 'red');
$(htmlInputText).find('#EMP_BestPhone').css('background', 'red');
where htmlInputText contains the whole input tag with this Id like:
<input type="text" class="dforms_be_input_limits" name="EMP_BestPhone" id="EMP_BestPhone" maxlength="10" data-type="int" title="">
Target the Id