$acn(ELEMENT as element/string/array of ELEMENTs, CLASSNAME as string)


ELEMENTDOM ElementstringDOM Element Array

The element(s) to add the class. Can be a single DOM element, an element ID specified as a string, or an array of DOM Element objects. If specifying the ID as a string, the ID corresponds to the value for the id HTML attribute for the element you wish to assign a style.


The class to add to the element(s). The class is appended to any existing classes already assigned to the element(s).


The $acn() function adds the class name to the passed-in HTML element(s). This will not overwrite any class names the already being using by the element(s). Instead, the new CSS classes will be used in addition to the class names already in use on the element(s). The added class name is the added as the last class name in the list of class names for the element. This means that any style attribute that duplicates a style attribute in one of the existing class names will override the existing style attribute.

This function is particular useful for adding an 'error' class name to an element when you want to highlight an error. Another typical use of this function is to add add some temporary styling to an element, such as when the element gets focus.


/*Assume that after a validation error, you want to indicate an error. The 'inputError' class might set the element's border color to red.
The 'firstname' control already has a class name (such as 'formInput'). You want to keep this class name, and add the error class name as an additional class name.*/
/*Add to the class names of multiple elements.*/
Use {dialog.object}.getPointer() to get the DOM element for a control.

See Also