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 the 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]
optional

The element or selector to change.

If omitted, the targeted fragment will be changed.

Type: Element | string
attributes
required

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.

Type: Object