addClass()

Adds the specified class(es) to each element in a set of HTML elements that match the selector of the script or of another query in the template (see query()). This has no effect if the class is already present.

addClass(classname)

Adds the specified class(es) to each element in a result set. Has no effect if the class is already present.

classname

String, space separated list of class names.

Examples

This script adds a class name to a paragraph.

results.addClass("foo");
Selector Matched element Matched element after script execution
p ​<p>Hello world</p> <p class="foo bar">Hello world</p>​


The following script adds two class names to a paragraph.

results.addClass("foo bar");
Selector Matched element Matched element after script execution
p ​<p>Hello world</p> <p class="foo bar">Hello world</p>​
 
  • Last Topic Update: 22, December, 2016 10:34 AM
  • Last Published: 23, May, 2019 01:55 PM