html()

html() : String

Returns the inner HTML of the first element in this result set.

html(value)

Replaces the inner HTML of each element in this result set by the supplied value.

value

A String that may contain HTML tags.

Examples

The following script loads part of a snippet based on the value of a field, and then inserts the content into the document using html().

var promoTxt = loadhtml('snippets/promo-en.html', '#' + record.fields['YOGA']); 
results.html(promoTxt);

The following script loads a snippet. Then it looks for a placeholder (@var2@) in the text of that snippet and replaces every found placeholder by the text '<i>OL Connect 1</i>'. It uses html() so the HTML formatting (<i> and </i>) will indeed be interpreted as HTML. Finally, it places the snippet in the template.

var mysnippet = loadhtml('snippets/snippet.html'); 
mysnippet.find('@var1@').html('<i>OL Connect 1</i>');
results.replaceWith(mysnippet);
 
  • Last Topic Update: 22, December, 2016 10:34 AM
  • Last Published: 23, May, 2019 01:55 PM