new Insertion.Before(element, html)
将 html
插入到页面中作为 element
的前导兄弟节点。
从 Prototype 1.6 开始,Insertion
类已经完全被 Element#insert 取代。
注意,如果插入的 HTML 包含有 <script>
标签,在插入后标签中的脚本会被自动执行 (Insertion.Before
在内部调用 String#evalScripts)。
<div>
<p id="modern_major_general">
I am the very model of a modern major general.
</p>
</div>
new Insertion.Before(
'modern_major_general',
"<p>In short, in all things vegetable, animal, and mineral...</p>"
);
<div>
<p>
In short, in all things vegetable, animal, and mineral...
</p>
<p id="modern_major_general">
I am the very model of a modern major general.
</p>
</div>