Michael, You were right my markup was a little messed up. I cleaned it up and used $('#master').children().size() and it worked for what I needed. Thanks for your quick response and you detailed explanation.
Thanks again, Ronn On Thu, Sep 4, 2008 at 11:44 AM, Michael Geary <[EMAIL PROTECTED]> wrote: > Ronn, your description doesn't match your code. The description says you > want to "count the 'group#' divs inside of the 'master' div", but the code > counts the immediate children of the #master div. > > Now, given the HTML you posted, those happen to be the same value, since > the only immediate children of #master are the group divs. Just checking > that this assumption will remain valid. > > Assuming that you actually want to count the immediate children of > div#master, your code looks like it should work. What result does it give > you? > > I would probably do it this way: > > var ct = $('#master > *').length; > > But that should give the same result. (You might try it just for > comparison.) > > Can you post a link to a test page? It's hard to tell what might be wrong > without seeing it in action. > > And do you have Firebug? You can open your page and try stuff out in the > Firebug console (click in the single line at the bottom of the console to > enter JavaScript code). Try these and see what you get (you can use the up > arrow key to bring back a previous entry, so you don't have to retype the > whole thing each time): > > $('#master') > > $('#master').children() > > $('#master').children().size() > > $('#master > *') > > $('#master > *').length > > -Mike > > ------------------------------ > *From:* Ronn Ross > Hello all > I have seen examples of counting children of an element like a div. I have > tried to customize those examples to work for my situation, but with no > success. What I'm trying to accomplish seems simple, but I have not been > able to make it happen. I'm simply trying to count the 'group#' divs inside > of the 'master' div. I was hoping that something like: > > var ct = $('#master').children().size(); > > would work, but being new to JQuery I have not been able to find a > solution. > Thanks in advance, > > <div id="master"> > <div id="group1"> > <table> > <tr> > <td> > content inside area > </td> > </tr> > </table> > </div> > <div id="group2"> > <table> > <tr> > <td> > content inside area > </td> > </tr> > </table> > </div> > </div> > >