1 <!doctype html> 2 <html> 3 <head> 4 <title>document.getElementsByClassName(): adding element with class</title> 5 <script src="resources/common.js"></script> 6 </head> 7 <body class="a"> 8 <p id="r">FAIL (script did not run)</p> 9 <script> 10 var collection = document.getElementsByClassName("a"), 11 ele = document.createElement("foo"); 12 ele.setAttribute("class", "a"); 13 document.body.appendChild(ele) 14 t(collection, [document.body, ele]) 15 </script> 16 </body> 17 </html> 18