HTML事件属性onggle
HTML事件属性onggle
触发 ontoggle 属性事件当打开或关闭< details> 元件。
HTML5中的新功能
ontoggle 属性在HTML5中是新的。
句法
<details ontoggle="script">
支持的标签
<details>浏览器兼容性
|
|
|
|
|
|
|---|---|---|---|---|---|
details |
Yes | No | No | Yes | Yes |
例子
<!DOCTYPE html>
<html>
<body>
<details ontoggle="myFunction()">
<summary>Open the summary</summary>
<p>this is a test.</p>
</details>
<script>
function myFunction() {
console.log("The ontoggle event occured");
}
</script>
</body>
</html>