[jQuery] Re: Counting the number of child elements that a div has

2007-10-03 Thread wattaka

Thanks Wizzud, but this does not work with elements that are
dynamically added to the DOM, is there another way? Thanks

On Oct 3, 11:26 pm, Wizzud [EMAIL PROTECTED] wrote:
 var ct = $('div').children().size();

 wattaka wrote:

  How can I count the number of child elements that a div container has?
  Thanks

 --
 View this message in 
 context:http://www.nabble.com/Counting-the-number-of-child-elements-that-a-di...
 Sent from the jQuery General Discussion mailing list archive at Nabble.com.



[jQuery] Re: Counting the number of child elements that a div has

2007-10-03 Thread Scott Trudeau
It should. I just typed this into my Firebug console on a page including
jQuery:

$('body').append('div id=test/div');

$('#test').append('p'+ $('#test').children().size()  +'/p');

$('#test').append('p'+ $('#test').children().size()  +'/p');

$('#test').append('p'+ $('#test').children().size()  +'/p');

Seemed to work as expected

Scott

On 10/3/07, wattaka [EMAIL PROTECTED] wrote:


 Thanks Wizzud, but this does not work with elements that are
 dynamically added to the DOM, is there another way? Thanks

 On Oct 3, 11:26 pm, Wizzud [EMAIL PROTECTED] wrote:
  var ct = $('div').children().size();
 
  wattaka wrote:
 
   How can I count the number of child elements that a div container has?
   Thanks
 
  --
  View this message in context:
 http://www.nabble.com/Counting-the-number-of-child-elements-that-a-di...
  Sent from the jQuery General Discussion mailing list archive at
 Nabble.com.




-- 
--
Scott Trudeau
scott.trudeau AT gmail DOT com
http://sstrudeau.com/
AIM: sodthestreets


[jQuery] Re: Counting the number of child elements that a div has

2007-10-03 Thread Brandon

http://docs.jquery.com/Core/length

$(#divid  #childrenids).length

or maybe $(#divid).children().length to get all of them no matter
what type of children elements they are


On Oct 3, 4:57 pm, wattaka [EMAIL PROTECTED] wrote:
 How can I count the number of child elements that a div container has?
 Thanks