Edit this page

up.Layer up.Layer.prototype.affix(selector, [attrs])
Instance method

This feature is experimental. Please share your experiences so we know what to keep or change.

Creates an element with the given selector and appends it to this layer's outmost element.

Also see up.element.affix().

Example

layer = up.layer.open()
element = layer.affix(.klass')
element.parentElement // returns 'main'
element.className // returns 'klass'

Parameters

Element

selector
required

The CSS selector from which to create an element.

string
[attrs]
optional

An object of attributes to set on the created element.

[attrs.text]
optional

The text content of the created element.

[attrs.content]
optional

The inner HTML of the created element.

[attrs.style]
optional

An object of CSS properties that will be set as the inline style of the created element. The given object must use kebab-case keys.

You may also pass a string with semicolon-separated styles.

Objectstring

Return value

The created element.