I have been playing around with this. http://www.commadot.com/jquery/selectorChildren.php
It's interesting to me how text and html act differently in terms of encoding and what actually shows up. It's also interesting to see how text nodes and a div are treated. I am confused. Why aren't the grandchildren being included in the call for children()? Using $("#content *") gets all the grandkids. I thought parents() gets all the grandparents. Is children different? Glen On 9/12/07, Richard D. Worth <[EMAIL PROTECTED]> wrote: > > On 9/12/07, Stephan Beal <[EMAIL PROTECTED]> wrote: > > > > > > On Sep 12, 9:20 pm, "John Resig" <[EMAIL PROTECTED]> wrote: > > > .html() only gets the innerHTML for the first matched element. > > > > i think that's what the OP is saying: the element's HTML he's getting > > back is *not* that of the first child element: > > > > > > <div id="content"> > > > > <div id="panelPreview" class="fieldset_theme"> > > > > <div id="panelPreview_inner" class="hPanel"> > > > > ... > > > > </div> > > > > </div> > > > > </div> > > > > Now his children() call: > > > > > > alert($('#content').children().html()); > > > > should return a result starting with <div id="panelPreview"...> > > > as John pointed out, html() returns innerHTML, not outer, so <div > id="panelPreview"...> should only be expected if $('#content').html() were > called. > > Breaking down $('#content').children().html() : > 1. $('#content') selects the outermost div which has an innerHTML of > <div id="panelPreview" class="fieldset_theme"> > <div id="panelPreview_inner" class="hPanel"> > <fieldset> > <legend>[Section/Panel Heading]</legend> > </fieldset> > </div> > </div> > > 2. .children() selects all its children, in this case there's only 1 - > #panelPreview which has an innerHTML of > <div id="panelPreview_inner" class="hPanel"> > <fieldset> > <legend>[Section/Panel Heading]</legend> > </fieldset> > </div> > > 3. .html() returns the innerHTML of the first element in the > selection/first child of #content. See step 2 > > Looks correct to me, though maybe not what's wanted. > > - Richard > >