O'Reilly logo

Prototype and Scriptaculous: Taking the Pain out of JavaScript by Chris Angus

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

3.4. Manipulating Documents

Prototype provides utilities for manipulating documents via the Insertion objects.

Insertion.Before Inserts content before an element
Insertion.After Inserts content after an element
Insertion.Top Inserts content at the top of an element
Insertion.Bottom Inserts content at the bottom of an element

These are called via:

new Insertion.function('id',content);

For example, the code:

<span id='result'>The result is:</span>
<a href="javascript:void (new Insertion.Bottom('result','100'))">click for result</a>

results in the text The result is:100 being displayed.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required