Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Data Attributes

HTML5 gives us the ability to use custom data attributes on elements:

<div data-foo="bar"></div>

For working with data attributes, jQuery has several methods:

get all values as key-value pairs: { key: value }

get a value by key

set a value

set multiple values

remove a value by key or keys

remove multiple values

An interactive example:

Last updated