编辑下面的代码:【加编码】
<html> <body> <p>该实例演示了如何使用 addEventListener()方法向 details 元素中添加 "ontoggle" 事件。</p> <p>打开详细信息。</p> <details id="myDetails"> <summary>Copyright 1999-2014.</summary> <p> - by Refsnes Data. All Rights Reserved.</p> <p>All content and graphics on this web site are the property of the company Refsnes Data.</p> </details> <p><strong>注意:</strong> 目前只有 Chrome, Safari 6+, 和 Opera 15+ 浏览器支持 details 元素和 ontoggle 属性。</p> <script> document.getElementById("myDetails").addEventListener("toggle", myFunction); function myFunction() { alert(" ontoggle 事件触发"); } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂