field().node()
Get the container node for the field.
Please note - this property requires the Editor extension for DataTables.
Description
When working with forms, you often want to interact directly with the form elements. This method will return the DOM container element for the requested field, allowing standard jQuery / DOM manipulation of the field.
If you require a reference to the field's input element, use the field().input() method rather than this one as it is simpler and more direct.
Note that the node() method provides the same functionality as this method for a single field, and extends that ability to be able to operate with multiple fields if required.
Type
field(…).node()
Examples
Dynamically add a class to a field's container:
$(editor.field('account_type').node()).addClass('account');Attach a change event handler to a field to show and hide an additional field on value selection:
// Note that to obtain a reference to the input element you also use the
// `field().input()` method in Editor 1.4+ which is simpler and more reliable!
$('input', editor.field('dept').node()).on('change', function () {
if (editor.field('dept').val() === 'Marketing') {
editor.show('marketing-section');
}
else {
editor.hide('marketing-section');
}
});