Document-getElementsByClassName.html (820B)
1 <!DOCTYPE html> 2 <title>Document.getElementsByClassName</title> 3 <link rel="author" title="Intel" href="http://www.intel.com"> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <div id="log"></div> 7 <script> 8 test(function() { 9 var a = document.createElement("a"), 10 b = document.createElement("b"); 11 a.className = "foo"; 12 this.add_cleanup(function() {document.body.removeChild(a);}); 13 document.body.appendChild(a); 14 15 var l = document.getElementsByClassName("foo"); 16 assert_true(l instanceof HTMLCollection); 17 assert_equals(l.length, 1); 18 19 b.className = "foo"; 20 document.body.appendChild(b); 21 assert_equals(l.length, 2); 22 23 document.body.removeChild(b); 24 assert_equals(l.length, 1); 25 }, "getElementsByClassName() should be a live collection"); 26 </script>