I have a code:
My question is: what am I doing wrong that it does not show me the correct number of tags h4 searched elements?Code:<ul id="list_people"> <li> <h4>A<!-- There should add: 3 --></h4> <ul> <li>Adamski Piter</li> <li>Amart Jan</li> <li>Azyl Pawel</li> </ul> </li> <li> <h4>B<!-- There should add: 2 --></h4> <ul> <li>Bamer Anna</li> <li>Bit Miron</li> </ul> </li> <li> <h4>C<!-- There should add: 1 --></h4> <ul> <li>Cel Maciej</li> </ul> </li> </ul> <script type="text/javascript"> var number_of_sections=$('#list_people h4').size(); var people_in_the_section=[]; for(var i=0; i<number_of_sections; i++) { people_in_the_section[i]=$("#list_people li ul lil:eq(" + i + ")").size(); $("#list_people h4:eq(" + i + ")").append(people_in_the_section[i]); } </script>


Reply With Quote


Bookmarks