Per jQuery API Docs
The .data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks.
The .data()
method will not modify the existing DOM node, but will only be retrievable via calling of $selector.data()
. Your DOM elements don't change, just the data attached to them.