日期:2014-05-17 浏览次数:20501 次
require('phpQuery/phpQuery.php'); $doc['ul > li'] ->addClass('my-new-class') ->filter(':last') ->addClass('last-li') ->toReference($li); foreach($ul['> li'] as $li) { // iteration returns PLAIN dom nodes, NOT phpQuery objects $tagName = $li->tagName; $childNodes = $li->childNodes; // so you NEED to wrap it within phpQuery, using pq(); pq($li)->addClass('my-second-new-class'); }