CanvasRenderingContext2D.canvas
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.
CanvasRenderingContext2D.canvas
はキャンバス API の一部で、このコンテキストに関連付けられた HTMLCanvasElement
オブジェクトへの読み取り専用の参照です。 <canvas>
に関連づけられていない場合は null
になることがあります。
構文
js
ctx.canvas;
例
この <canvas>
要素があるとします。
html
<canvas id="canvas"></canvas>
CanvasRenderingContext2D
の中にある canvas 要素への参照は、 canvas
プロパティから取得することができます。
js
var canvas = document.getElementById("canvas");
var ctx = canvas.getContext("2d");
ctx.canvas; // HTMLCanvasElement
仕様書
Specification |
---|
HTML # dom-context-2d-canvas-dev |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
canvas |
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.
関連情報
CanvasRenderingContext2D
インターフェイス- キャンバス API