Edit this page

up.syntax up.data(element)
JavaScript function

Returns the given element's [up-data], parsed as a JavaScript object.

Returns undefined if the element has no [up-data] attribute.


You have an element with JSON data serialized into an up-data attribute:

<span class='person' up-data='{ "age": 18, "name": "Bob" }'>Bob</span>

Calling up.syntax.data() will deserialize the JSON string into a JavaScript object:

up.syntax.data('.person') // returns { age: 18, name: 'Bob' }


element stringorElementorjQuery

The element for which to return data.

Return value

The JSON-decoded value of the up-data attribute. Returns undefined if the element has no (or an empty) up-data attribute.

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