Edit this page

up.element up.element.createFromHTML(html)
JavaScript function

Creates an element from the given HTML fragment string.

Use up.hello() to activate JavaScript behavior within the created element.

Example

element = up.element.createFromHTML('<div class="foo"><span>text</span></div>')
element.className // returns 'foo'
element.children[0] // returns <span> element
element.children[0].textContent // returns 'text'

Parameters

html string

A string of HTML from which to create the element.

The given HTML must have a single tag at its root or an error is thrown.

This website uses cookies to improve usability and analyze traffic.
I accept or learn more