只读
numberValue
特性为
XPathResult
interface returns the numeric value of a result with
XPathResult.resultType
being
NUMBER_TYPE
.
var value = result.numberValue;
The return value is the numeric value of the
XPathResult
返回通过
Document.evaluate()
.
若
XPathResult.resultType
不是
NUMBER_TYPE
,
XPathException
类型
TYPE_ERR
is thrown.
The following example shows the use of the
numberValue
特性。
<div>XPath example</div> <div>Number of <div>s: <output></output></div>
var xpath = "count(//div)";
var result = document.evaluate(xpath, document, null, XPathResult.NUMBER_TYPE, null);
document.querySelector("output").textContent = result.numberValue;
| 规范 | 状态 | 注释 |
|---|---|---|
|
DOM (文档对象模型) 3 级 XPath 规范
The definition of 'XPathResult.numberValue' in that specification. |
推荐 | 初始定义 |
No compatibility data found. Please contribute data for "api.XPathResult.numberValue" (depth: 1) to the MDN 兼容性数据存储库 .