Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting multiple children with same parent in CSS

Tags:

jquery

css

php

I'm using PHPQuery, which is a PHP port of jQuery, so it also uses CSS selectors. However, one difference is that PHPQuery does not return matched elements in the document order when there are multiple selectors.

Is it possible to combine this into one selector?

#article>p,#article>blockquote

The only other solution I can think of is:

#article>*:not(div):not(table):not(ul):not(...
like image 312
Leo Jiang Avatar asked Feb 25 '26 10:02

Leo Jiang


1 Answers

I haven't used phpQuery(till 5 minutes ago) but as it works like jQuery, using it's .filter() method should do the trick, the idea is selecting all the children and then filtering the elements that match the criteria.

$doc['#article']->children()->filter(function($i, $element) {
    return in_array($element->tagName, array('blockquote', 'p'));
})->foo();
like image 185
undefined Avatar answered Feb 27 '26 03:02

undefined