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