Edit this page

up.Preview up.Preview.prototype.setAttrs([element], attributes)
Instance method

Temporarily changes an element's attributes.

The element's original attributes will be restored when whe preview ends.

Example

This preview sets a temporary [app-loading=true] attribute on the targeted fragment:

up.preview('loading-attr', function(preview) {
  preview.setAttrs({ 'app-loading': true })
})

Parameters

[element=this.fragment] Element|string optional

The element or selector to change.

If omitted, the targeted fragment will be changed.

attributes Object

An object of attribute names and values to set.

To set an empty attribute, pass an empty string value.

To remove an attribute, use a value of null or undefined.