GOT IT, THANKS :)! On Jan 13, 3:02 pm, Walter Lee Davis <[email protected]> wrote: > If there's only one of them that you want to insert, then either it > has an ID, and you use that: > > var myDiv = $('element_to_insert_after_foo'); > // where you are getting <div id="element_to_insert_after_foo"></div> > > ...or you use the slightly riskier class-based selector: > > var myDiv = $$('.element_to_insert_after_foo').first(); > // where you are getting the first <div > class="element_to_insert_after_foo"></div> > > Double-dollar ALWAYS returns an array, sometimes an empty one (if your > selector didn't match anything), but usually populated with extended > DOM objects. You can't insert an array of objects into the page, only > one at a time. If you wanted to insert all of the matching objects in > a loop, then you could use: > > var myDivs = $$('.element_to_insert_after_foo'); > myDivs.each(function(elm){ $('foo').insert({after: elm}); }); > > Walter > > On Jan 13, 2010, at 8:53 AM, [email protected] wrote: > > > > > Thanks, > > > its working fine with a id. But how can i get > > "element_to_insert_after_foo" if this is a class element? > > This is also not working: > > > var myDiv = $$('.element_to_insert_after_foo'); > > Element.insert($('foo'), {'after':myDiv} ); > > > On 13 Jan., 12:36, "T.J. Crowder" <[email protected]> wrote: > >> Hi, > > >> You're using `$$` to get the element_to_insert_after_foo, which > >> returns an array (probably an empty one, since the selector is > >> unlikely to match anything). You want to use `$` instead. > > >> HTH, > >> -- > >> T.J. Crowder > >> Independent Software Consultant > >> tj / crowder software / comwww.crowdersoftware.com > > >> On Jan 13, 9:55 am, "[email protected]" > > >> <[email protected]> wrote: > >>> Hello all, > > >>> in need to insert a existing dom element behind the mother dom. > >>> For Example: > > >>> <div id="foo"> > >>> <div class="element_to_insert_after_foo"></div> > >>> </div> > > >>> After Insert: > > >>> <div id="foo"></div> > >>> <div class="element_to_insert_after_foo"></div> > > >>> I tried as follow but nothing happens: > > >>> var myDiv = $$('element_to_insert_after_foo'); > >>> Element.insert($('foo'), {'after':myDiv} ); > > >>> Thanks for help! > > -- > > You received this message because you are subscribed to the Google > > Groups "Prototype & script.aculo.us" group. > > To post to this group, send email to > > [email protected] > > . > > To unsubscribe from this group, send email to > > [email protected] > > . > > For more options, visit this group > > athttp://groups.google.com/group/prototype-scriptaculous?hl=en > > .
-- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.
