Html程序  |  18行  |  474 B

<!doctype html>
<html>
 <head>
  <title>document.getElementsByClassName(): adding element with class</title>
  <script src="resources/common.js"></script>
 </head>
 <body class="a">
  <p id="r">FAIL (script did not run)</p>
  <script>
   var collection = document.getElementsByClassName("a"),
       ele = document.createElement("foo");
   ele.setAttribute("class", "a");
   document.body.appendChild(ele)
   t(collection, [document.body, ele])
  </script>
 </body>
</html>