array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'dom-parentnode.queryselector.php', 1 => 'Dom\\ParentNode::querySelector', 2 => 'Returns the first element that matches the CSS selectors', ), 'up' => array ( 0 => 'class.dom-parentnode.php', 1 => 'Dom\\ParentNode', ), 'prev' => array ( 0 => 'dom-parentnode.prepend.php', 1 => 'Dom\\ParentNode::prepend', ), 'next' => array ( 0 => 'dom-parentnode.queryselectorall.php', 1 => 'Dom\\ParentNode::querySelectorAll', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/dom/dom/parentnode/queryselector.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

Dom\ParentNode::querySelector

(PHP 8 >= 8.4.0)

Dom\ParentNode::querySelectorReturns the first element that matches the CSS selectors

说明

public Dom\ParentNode::querySelector(string $selectors): ?Dom\Element

Returns the first element that matches the CSS selectors specified in selectors.

参数

selectors
A string containing one or more CSS selectors.

返回值

Returns the first Dom\Element that matches selectors. Returns null if no element matches.

错误/异常

Throws a DOMException with code Dom\SYNTAX_ERR when selectors is not a valid CSS selector string.

参见