.removeData([name|list]) deletes values previously stored with .data() from jQuery’s internal cache (since 1.2.3; bulk keys since 1.7). With no arguments, it clears all cached values.
Remember
$div.data("test1", "VALUE-1")
$div.removeData("test1") // one key
$div.removeData(["a", "b"]) // bulk (1.7+)
$div.removeData("a b") // space-separated (1.7+)
$div.removeData() // clear all
// HTML data-* attributes are NOT removed
Select elements, choose keys (or none), clear the cache.
Select the element(s) that hold jQuery data.
Pass one key, a list of keys (1.7+), or nothing to clear all.
Call .removeData(…) — the element stays in the DOM.
If HTML data-* must go too, also call .removeAttr().
Piece
Required?
Role
jQuery collection
Yes
Elements whose cache to update
name / list
Optional
Key(s) to delete; omit to clear all
Return
—
Same collection (chainable)
Pseudocode
Pseudocode
for each element in matched set:
if no arguments:
clear entire jQuery data cache
else if list of keys:
delete each named key
else:
delete that one key
// HTML data-* attributes unchanged
// Official idea:
data("test1", "VALUE-1")
data("test2", "VALUE-2")
removeData("test1")
→ test1 gone; test2 still there
Reference
Cheat Sheet
Keep these facts handy while clearing the data cache.
removeData alone. Cache cleared, but the attribute remains.
Next read. jQuery can re-fetch from the attribute → "card" again.
Fix. Also .removeAttr("data-role") so later reads stay empty.
Edge Cases & Pitfalls
Check these before relying on .removeData() in widgets.
attrs
data-* survives
Use .removeAttr() with .removeData() when the HTML attribute must go too.
bulk
Bulk getter caches once
The all-keys .data() getter may not re-fetch data-* after removeData between calls — official jQuery note.
detach
Detached nodes keep data
.detach() preserves the cache. Clear it explicitly if you need a clean slate.
remove
.remove() already cleans up
Deleting the element with .remove() also clears its jQuery data.
Compatibility
Browser Support
.removeData() is a core jQuery method (since 1.2.3; bulk keys since 1.7). It needs a browser DOM with jQuery loaded.
✓ jQuery 1.2.3+ · Browsers only
jQuery .removeData()
Works in Chrome, Firefox, Safari, Edge, and other browsers with jQuery. Not for Node.js without a DOM.
100%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
.removeData()Browsers
Bottom line: Use .removeData() in the browser to clear the data cache. Remember: HTML data-* attributes are separate.
Analysis
Performance Notes
Approach
Cost
Best for
.removeData(key)
Very low
Clearing one option / flag
.removeData([…])
Very low
Resetting a small set of keys
.removeData()
Low
Full reset before re-init
Prefer targeted key removal when possible. Full clears are fine for teardown; avoid repeatedly wiping and re-seeding in hot loops.
Remember
Key Takeaways
Role: delete values from jQuery’s internal .data() cache.
Scope: one key, a list, or all — element stays in the DOM.
Attrs: HTML data-* needs .removeAttr() too.
Pair with:.data() to store; hasData to check.
One line:.removeData(key) clears the cache — not the HTML attribute, and not the element itself.
Frequently Asked Questions
.removeData(name) deletes one value from jQuery's internal data cache on matched elements. With no arguments, it clears all cached values. Returns the jQuery collection for chaining. Available since jQuery 1.2.3.
.data() stores values; .removeData() deletes them from the same cache. Use .data() for plugin state and .removeData() when resetting or destroying a widget.
No. It only clears jQuery's internal cache. data-* attributes stay in the DOM, so a later .data('key') may re-read data-key. Pair with .removeAttr('data-key') when you need both gone.
Yes, since jQuery 1.7. Pass an array — .removeData(['foo', 'bar']) — or a space-separated string — .removeData('foo bar').
.removeData() clears cached values but keeps the element. .remove() deletes the element from the DOM and also cleans up its data and events.
When resetting widget state, clearing stale options, or cleaning up before re-init on the same element. Elements removed with .remove() already lose their cache; detached nodes keep it until you clear it.