English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Referenzhandbuch

Vollständiges Verzeichnis der HTML-Tags

HTML ontoggle-Event-Attribut

HTML Event Attributes

Online-Beispiel

Führt JavaScript aus, wenn das <details>-Element geöffnet oder geschlossen wird:

<!DOCTYPE html>
<html>
<head>
<title>Verwendung des HTML ontoggle-Event-Attributs (Basis-Tutorial-Web oldtoolbag.com)</title>/title>
<style>
div {
  background: yellow;
  border: 1px solid #cccccc;
  padding: 10px;
}
</style>
</head>
<body>
<p>Öffnen Sie die Details.</p>
<details ontoggle="myFunction()">
<summary>Urheberrecht 1999-2019.</summary>
<p> - Alle Rechte vorbehalten./p>
<p>Details und Absätze werden hier dargestellt.../p>
</details>
<p><strong>Hinweis:</Der ontoggle-Event-Attribut wird von Chrome und Safari unterstützt 6+, und Opera 15+.</p>
<script>
function myFunction() {
  alert("ontoggle event triggered");
}
</script>
</body>
</html>
Test to see ‹/›

Definition and Usage

When the user opens or closes the <details> element, the ontoggle attribute is triggered.
The <details> element specifies other detailed information that the user can view or hide as needed.

Browser Compatibility

IEFirefoxOperaChromeSafari

HTML 4.01 with HTML5 differences

In HTML5In, the ontoggle attribute is newly added.

Syntax

<element ontoggle="script">

Attribute Value

ValueDescription
scriptScript is executed in ontoggle
Technical Details
Supported HTML Tags:<details>

Related Pages

HTML DOM Reference Manual: ontoggle Event


HTML Event Attributes