Prototype element insert example
1If you’re like me, you found the documentation on prototype’s insert method lacking much needed documentation http://www.prototypejs.org/api/element/insert . They say the format is like
insert(element, { position: content }) -> HTMLElement
What the heck does that mean? Obviously you can’t just paste it in because it’ll cause a JavaScript error. After some googling and trial and error, I have the code working and will provide it as an example. The code create a div with content and places it at the bottom of an existing page element.
//create new div var myDiv = new Element( 'div' ); //put product name in the new div myDiv.update('text inside the div'); //append div to page element Element.insert($('pageElement'), {'bottom':myDiv} );
Hi I'm Nick Bartlett and thanks for visiting my blog. I'm not much of a writer; many of my posts are short and to the point while others are meant to be a reference for myself and other web developers.
Can I insert a div at the bottom of a div element?
I tried to do
$(‘mydiv’).insert(new Element(“img”,{id:”myimage”,src:”images/ltr.png”}),{bottom:”myimage”});
mydiv is my parent div and I want myimage to be at the bottom of mydiv. Is it possible in any way