->each returns DOMElement instead of DomQuery
torian257x opened this issue ยท 3 comments
torian257x commented
is that on purpose?
e.g. I cannot do
$dq->find('select[name="myname"]')->each(function ($el, $i){
/** @var \DOMElement $el */
$linktag = $el->parent(); //meeep parent doesn't exist on DOMElement
});
Rct567 commented
Yeh it is, see also: https://api.jquery.com/each/
If you want the result as an DomQuery instance you can just use a foreach loop.
torian257x commented
@Rct567 ahh thanks
well in jquery you can do
->each(function(el){
var jel = $(el);
jel.parent();
});
is there something equivalent?
Rct567 commented
The constructor also accepts DOMNode/DOMElement, so just use new DomQuery
(or DomQuery::create
) instead of $
๐