class Nokogiri::XML::Node
def add_class(names)
node.add_class(["section", "header"]) # =>
node # =>
*Example:* Ensure that the node has CSS classes "section" and "header", via an Array argument
node.add_class("section header") # =>
node # =>
Note also that the pre-existing duplicate CSS class "section" is not removed.
Note that the CSS class "section" is not added because it is already present.
*Example:* Ensure that the node has CSS classes "section" and "header", via a String argument
node.add_class("section") # => # duplicate not added
node.add_class("section") # =>
node # =>
*Example:* Ensure that the node has CSS class "section"
[Returns] +self+ (Node) for ease of chaining method calls.
exists, one is created.
will not be added. Any class names not present will be added. If no "class" attribute
whitespace-delimited names, or an Array of String names. Any class names already present
CSS class names to be added to the Node's "class" attribute. May be a string containing
- +names+ (String, Array
[Parameters]
See related: #kwattr_add, #classes, #append_class, #remove_class
node.kwattr_add("class", names)
This is a convenience function and is equivalent to:
"class" attribute are not removed. Compare with #append_class.
in the "class" attribute are _not_ added. Note that any existing duplicates in the
Ensure HTML CSS classes are present on +self+. Any CSS classes in +names+ that already exist
:call-seq: add_class(names) → self
def add_class(names) kwattr_add("class", names) end