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 content.
For the root layer the element is appended to the <body>.
For an overlay it is appended to the overlay's top-level content element, like its <main>.
Also see up.element.affix().
Example
layer = await up.layer.open({ content: '<main></main>' })
element = layer.affix('.klass')
element.parentElement // returns the <main> element
element.className // returns 'klass'
Element
selector
required
The CSS selector from which to create an element.
Type: string
[attrs]
[attrs.text]
General
[attrs.content]
[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.
Type: Object | string
Return value
The created element.
Type: Element