onclick
onclick 属性は、要素がクリックされたときに実行するスクリプトを指定します。
37 個の要素がこの属性を使用します。 <a>, <altGlyph>, <animate>, <animateMotion>, <animateTransform>,
<circle>, <defs>, <desc>, <ellipse>, <foreignObject>, <g>,
<image>, <line>, <linearGradient>, <marker> (en-US), <metadata>, <mpath>,
<path>, <pattern>, <polygon>, <polyline>, <radialGradient>, <rect>,
<script>, <set>, <stop>, <style> (en-US), <svg>, <switch>,
<symbol> (en-US), <text>, <textPath> (en-US), <title>, <tref> (en-US), <tspan>,
<use>, <view> (en-US)
html
<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="100" r="100" onclick="alert('You have clicked the circle.')" />
</svg>
使用上のメモ
| 値 | <anything> |
|---|---|
| 既定値 | なし |
| アニメーション | 不可 |
仕様書
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2 # EventAttributes |
ブラウザーの互換性
BCD tables only load in the browser