XPathResult: numberValue プロパティ
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
numberValue
は XPathResult
インターフェイスの読み取り専用プロパティで、 XPathResult.resultType
が NUMBER_TYPE
である結果の数値を返します。
メモ: この機能はウェブワーカー内で利用可能です。
値
返値は Document.evaluate()
が返す XPathResult
の数値です。
例外
TYPE_ERR
XPathResult.resultType
が NUMBER_TYPE
でない場合、 TYPE_ERR
型の XPathException
が発生します。
例
次の例では numberValue
プロパティを使用しています。
HTML
html
<div>XPath example</div>
<div>Number of <div>s: <output></output></div>
JavaScript
js
const xpath = "count(//div)";
const result = document.evaluate(
xpath,
document,
null,
XPathResult.NUMBER_TYPE,
null,
);
document.querySelector("output").textContent = result.numberValue;
結果
仕様書
Specification |
---|
DOM # dom-xpathresult-numbervalue |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
numberValue |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.