public function QueryPath::removeClass in QueryPath 6
Same name and namespace in other branches
- 7.3 QueryPath/QueryPath.php \QueryPath::removeClass()
- 7.2 QueryPath/QueryPath.php \QueryPath::removeClass()
File
- QueryPath/
QueryPath.php, line 1539
Class
Code
public function removeClass($class) {
foreach ($this->matches as $m) {
if ($m
->hasAttribute('class')) {
$vals = explode(' ', $m
->getAttribute('class'));
if (in_array($class, $vals)) {
$buf = array();
foreach ($vals as $v) {
if ($v != $class) {
$buf[] = $v;
}
}
if (count($buf) == 0) {
$m
->removeAttribute('class');
}
else {
$m
->setAttribute('class', implode(' ', $buf));
}
}
}
}
return $this;
}