QueryPath\DOMQuery::addClass PHP Method

addClass() public method

This searchers for a class attribute on each item wrapped by the current DOMNode object. If no attribute is found, a new one is added and its value is set to $class. If a class attribute is found, then the value is appended on to the end.
See also: css()
See also: attr()
See also: removeClass()
See also: hasClass()
public addClass ( string $class )
$class string The name of the class.
    public function addClass($class)
    {
        foreach ($this->matches as $m) {
            if ($m->hasAttribute('class')) {
                $val = $m->getAttribute('class');
                $m->setAttribute('class', $val . ' ' . $class);
            } else {
                $m->setAttribute('class', $class);
            }
        }
        return $this;
    }