Yo.utils.writeHTML

Use this function to write any HTML string into the Document Object Model (DOM). You can insert the string before a specified DOM element, or append the string into the element at the end of the existing content. The DOM element must have a name or some other attribute that uniquely identifies it.

Prerequisite

The following command to load the appropriate version of the Rapid+JS Library must precede the use of this function on the page. Specify your own site key:

<script src="https://rapid-cdn.yottaa.com/rapid/lib/sitekey.js"></script>

Syntax

Yo.utils.writeHTML('DOM-element', 'html', 'action');

Parameters

Parameter

Description

DOM-element

DOM element to which to insert or append the HTML fragment. Can be a Yo.utils.select statement or any expression that resolves to a valid object reference.

html

HTML fragment as a string or DOM object.

Examples:

'<div>Hello, World</div>'

Yo.utils.select('#button-parent')

action

Specify one of the following actions: {insert | append}

Examples

This example adds a new button called myButton at the end of the DOM element called button-parent.

Yo.utils.writeHTML(Yo.utils.select('#button-parent'),"<button>myButton</button>",'append');

This example selects a DOM element called insertIntoMe, and appends to the end of its content the text "extraContent".

var insertHere = Yo.utils.select('insertIntoMe');
Yo.utils.writeHtml(insertHere,"<span>extraContent</span>","append");

Notes

<div> IDs in the DOM are required to be unique, otherwise the browser may produce unpredictable results, but the Rapid JS Library API does not enforce that uniqueness. It is up to you to ensure all <div> IDs in your application are unique.

In specifying a <div> using the ‘#string’ notation, the string must be the full ID of the element. When you specify a class name using ‘.string’, the string must be an equality of one of the class names that is on the specified DOM element. Elements can have multiple class names.