add query()

This commit is contained in:
Jaeger
2017-09-19 19:06:16 +08:00
parent 0fafaafa7b
commit 02c4c93ee5
2 changed files with 182 additions and 3 deletions

View File

@@ -30,7 +30,12 @@ class Elements
public function __call($name, $arguments)
{
$obj = call_user_func_array([$this->elements,$name],$arguments);
return $obj instanceof phpQueryObject?(new self($obj)):$obj;
if($obj instanceof phpQueryObject){
$obj = new self($obj);
}else if(is_string($obj)){
$obj = trim($obj);
}
return $obj;
}
public function map($callback)
@@ -49,5 +54,17 @@ class Elements
});
}
public function texts()
{
return $this->map(function($item){
return trim($item->text());
});
}
public function htmls()
{
return $this->map(function($item){
return trim($item->html());
});
}
}