And use a internal system of cache, so if you update the attr data you need to retrieve with attr().
Since jQuery 1.4.3, data-* attributes are used to initialize jQuery data. An element's data-* attributes are retrieved the first time the data() method is invoked upon it, and then are no longer accessed or mutated (all values are stored internally by jQuery).
Something that I learned from jQuery was the event delegation and is easy to implement:
A good thing to remember too is the
data()
method used in jQuery not set values indata
attr but can read it.docs
And use a internal system of cache, so if you update the attr data you need to retrieve with
attr()
.docs
Beautiful, thank you for pointing this out!
I haven't done much with jQuery event delegation, but I am guessing you need to be careful to turn off the listener if you need garbage collection?