mouse-click-change-details-to-display-none.html (882B)
1 <!DOCTYPE html> 2 <!-- Any copyright is dedicated to the Public Domain. 3 - http://creativecommons.org/publicdomain/zero/1.0/ --> 4 5 <html class="reftest-wait"> 6 <script> 7 function runTest() { 8 // Both Chrome and Safari add the 'open' attribute to the details element. 9 var details = document.getElementById("details"); 10 var summary = document.getElementById("summary"); 11 12 document.body.addEventListener("click", function () { 13 // Change details to display: none in capturing phase. 14 details.style.display = "none"; 15 }, true); 16 17 summary.dispatchEvent(new MouseEvent("click")); 18 19 details.style.display = "block"; 20 document.documentElement.removeAttribute("class"); 21 } 22 </script> 23 <body onload="runTest();"> 24 <details id="details"> 25 <summary id="summary">Summary</summary> 26 <p>This is the details.</p> 27 </details> 28 </body> 29 </html>