[jQuery] Re: get reference to nested appended element
thanks for the useful infomation! On Apr 7, 11:00 pm, mkmanning michaell...@gmail.com wrote: Caveat: Jonathan's method will get you the child table (the one with id rt0 from the original OP's example), however Eric's will get you all tables that are children of a table, within the context of the parent container. So in the latter case, if the parent already had a set of nested tables before youappendedthe new set, you'll get both child tables. On Apr 7, 1:02 pm, Eric Garside gars...@gmail.com wrote: parent.append(tabletrtdtable/table/td/tr/table); var table = $('table table', parent); Be sure to close your inner table tag. IE doesn't like when you try and generate fragments of code, iirc. On Apr 7, 12:28 pm, Jonathan Sharp, Out West Media jquery- li...@outwestmedia.com wrote: Another approach you can take is: var table = $('tabletrtdtable id=rt0/td/tr/table/td/tr/table') .appendTo( parent ) .find('table'); This creates the HTML and then appends it to the parent. Since you created a jQuery object with that fragment, calling find will locate the inner table. Cheers, - Jonathan On Tue, Apr 7, 2009 at 4:38 AM, miniswi...@gmail.com miniswi...@gmail.comwrote: hi there, see next example: parent.append(tabletrtdtable id=\rt0\//td/tr/table); table = $(#rt0); is it possible to reference the inside table directly without using the id to select it?
[jQuery] Re: get reference to nested appended element
Another approach you can take is: var table = $('tabletrtdtable id=rt0/td/tr/table/td/tr/table') .appendTo( parent ) .find('table'); This creates the HTML and then appends it to the parent. Since you created a jQuery object with that fragment, calling find will locate the inner table. Cheers, - Jonathan On Tue, Apr 7, 2009 at 4:38 AM, miniswi...@gmail.com miniswi...@gmail.comwrote: hi there, see next example: parent.append(tabletrtdtable id=\rt0\//td/tr/table); table = $(#rt0); is it possible to reference the inside table directly without using the id to select it?
[jQuery] Re: get reference to nested appended element
parent.append(tabletrtdtable/table/td/tr/table); var table = $('table table', parent); Be sure to close your inner table tag. IE doesn't like when you try and generate fragments of code, iirc. On Apr 7, 12:28 pm, Jonathan Sharp, Out West Media jquery- li...@outwestmedia.com wrote: Another approach you can take is: var table = $('tabletrtdtable id=rt0/td/tr/table/td/tr/table') .appendTo( parent ) .find('table'); This creates the HTML and then appends it to the parent. Since you created a jQuery object with that fragment, calling find will locate the inner table. Cheers, - Jonathan On Tue, Apr 7, 2009 at 4:38 AM, miniswi...@gmail.com miniswi...@gmail.comwrote: hi there, see next example: parent.append(tabletrtdtable id=\rt0\//td/tr/table); table = $(#rt0); is it possible to reference the inside table directly without using the id to select it?
[jQuery] Re: get reference to nested appended element
Caveat: Jonathan's method will get you the child table (the one with id rt0 from the original OP's example), however Eric's will get you all tables that are children of a table, within the context of the parent container. So in the latter case, if the parent already had a set of nested tables before you appended the new set, you'll get both child tables. On Apr 7, 1:02 pm, Eric Garside gars...@gmail.com wrote: parent.append(tabletrtdtable/table/td/tr/table); var table = $('table table', parent); Be sure to close your inner table tag. IE doesn't like when you try and generate fragments of code, iirc. On Apr 7, 12:28 pm, Jonathan Sharp, Out West Media jquery- li...@outwestmedia.com wrote: Another approach you can take is: var table = $('tabletrtdtable id=rt0/td/tr/table/td/tr/table') .appendTo( parent ) .find('table'); This creates the HTML and then appends it to the parent. Since you created a jQuery object with that fragment, calling find will locate the inner table. Cheers, - Jonathan On Tue, Apr 7, 2009 at 4:38 AM, miniswi...@gmail.com miniswi...@gmail.comwrote: hi there, see next example: parent.append(tabletrtdtable id=\rt0\//td/tr/table); table = $(#rt0); is it possible to reference the inside table directly without using the id to select it?