onclick

onclick attribute specifies some script to run when the element is clicked.

You can use this attribute with the following SVG elements:

范例

<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>
默认值 None
Animatable No

规范

规范 状态 注释
Scalable Vector Graphics (SVG) 2
The definition of 'onclick' in that specification.
候选推荐 无变化
Scalable Vector Graphics (SVG) 1.1 (Second Edition)
The definition of 'onclick' in that specification.
推荐 初始定义

浏览器兼容性

BCD tables only load in the browser

Found a problem with this page?

最后修改: , 由 MDN 贡献者