jQuery 的 replaceWith 的替代原型

Prototype alternative to jQuery's replaceWith

我有一小部分内容已使用 ajax 替换。但是,我仅限于原型:

function ajaxCartUpdateShippingNotice( productId ) {
    var aj = new Ajax.Request("/hint/block/index?id=" + productId, {
        method: "GET",
        onComplete: function( result ) {
            $( "#delivery--notice" ).replace( result );
        }
    });
};

我的HTML内容是这样的:

<div id="delivery--notice">
    <p>Some content here.</p>
</div>

而且我知道 jQuery 我可以做到;有没有办法用原型来做到这一点?

$( selector ).replaceWith( html );

直接从 the documentation:

Element.replace

Element.replace(element[, newContent]) → Element

Replaces element itself with newContent and returns element.

与大多数 PrototypeJS 一样,它也可以作为 a method on elements:

使用

Element#replace

Element#replace([newContent]) → Element

Replaces element itself with newContent and returns element.