You are here

public function QueryPath::addClass in QueryPath 6

Same name and namespace in other branches
  1. 7.3 QueryPath/QueryPath.php \QueryPath::addClass()
  2. 7.2 QueryPath/QueryPath.php \QueryPath::addClass()

File

QueryPath/QueryPath.php, line 1526

Class

QueryPath

Code

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;
}