6. remove-class

remove-class(class?, element?)

Remove CSS class class from the list of “interned” CSS classes of element element. Does nothing at all if element element does not have this CSS class.


The CSS class name to be removed. Defaults to "", which means: all classes.

  • class may be the empty string "", which means: remove all classes.

  • class may be a class name.

  • class may be a class pattern. In such case all class names matching the pattern are removed from the list.

    A class pattern has the following syntax: /pattern/ or ^pattern$ (which is equivalent to /^pattern$/), where pattern is a regular expression pattern.


The element from which class should be removed. Defaults to the context node, if the context node is an element.

For this command to work, command parse-styles must have been invoked in order to “intern” the CSS classes found in all the elements of the document being edited.


(: Remove all classes from context element. :)

(: Remove all classes from $figure. :)
remove-class("", $figure);

(: Remove class "role-inline-wrapper" from $para. :)
remove-class("role-inline-wrapper", $para);

(: Remove all classes matching "^role-.*ref-field$" 
   from context element. :)

See also add-class.

Related XPath extension functions: get-class.