Home | History | Annotate | Download | only in NodeList
      1 <html>
      2 <head>
      3 <link rel="stylesheet" href="../../js/resources/js-test-style.css">
      4 <script src="../../js/resources/js-test-pre.js"></script>
      5 </head>
      6 <body>
      7 <p id="description"></p>
      8 <div id='div1'>text1</div>
      9 <div id='div2'>text2</div><br>
     10 
     11 <div id="console"></div>
     12 
     13 <script>
     14 description('This tests that items in a NodeList can be retrieved by index.');
     15 
     16 var nodeList = document.getElementsByTagName('div');
     17 var div0 = nodeList[0];
     18 var div0s = nodeList["0"];
     19 var div0s_ = nodeList["0 "];
     20 var div1 = nodeList["1"];
     21 
     22 // Getting properties 0 and "0" should get the same thing, but getting
     23 // properties "0 " and 1 should get different items.  "0 " should not
     24 // be converted to 0, so should be undefined, and the item at index
     25 // 1 should be defined (since there are at least two divs on the page),
     26 // but should be a different div to the one at index 0.
     27 shouldBeTrue("div0 == div0s");
     28 shouldBeFalse("div0 == div0s_");
     29 shouldBeFalse("div0 == div1");
     30 shouldBeFalse("div0s == div0s_");
     31 shouldBeFalse("div0s == div1");
     32 shouldBeFalse("div0s_ == div1");
     33 
     34 var successfullyParsed = true;
     35 </script>
     36 <script src="../../js/resources/js-test-post.js"></script>
     37 </body>
     38 </html>
     39