Hi, > Anyone please help. What am I do wrong?!!
You're using the same `id` value on more than one element. That is invalid markup[1] and will not work correctly. `id` values *MUST* be unique on the page.[2][3] You may have wanted to use a `class`[4][5] instead: <div class="num">1</div> <div class="num">2</div> <div class="num">3</div> <div class="num">4</div> <div class="num">5</div> alert($$(".num").length); // "5" [1] http://validator.w3.org/ [2] http://www.w3.org/TR/html5/elements.html#the-id-attribute [3] http://www.w3.org/TR/html401/struct/global.html#adef-id [4] http://www.w3.org/TR/html5/elements.html#classes [5] http://www.w3.org/TR/html401/struct/global.html#adef-class HTH, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Jun 22, 2:33 pm, KingKong99 <k0818069...@gmail.com> wrote: > I have very simple code as below: > > <html> > <head> > <script src=prototype.js></script> > > <script> > document.observe('dom:loaded',function(){ > var nums = $$('#num'); > > alert(nums.length); > > }); > > </script> > > </head> > <body> > <div id=bb> > > <div id=num_container> > <div id=num>1</div> > <div id=num>2</div> > <div id=num>3</div> > <div id=num>4</div> > <div id=num>5</div> > </div> > > </div> > </body> > </html> > > There is no problem in Chrome or Firefox but IE8. It should alert > number 5 not 1. > > Anyone please help. What am I do wrong?!! > > Thank you > King -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.