jQuery.removeData(element [, name]) deletes values previously stored with jQuery.data(). This tutorial covers removing one key vs clearing all data, the official demo, how it differs from .removeData(), data-* pitfalls, five examples, and try-it labs.
After you attach values with jQuery.data() or .data(), you often need to clean them up — widget destroy, reset, or re-init. Since jQuery 1.2.3, jQuery.removeData(element [, name]) is the low-level way to delete those cached entries for a single DOM node.
Official docs note this is low-level: day to day, prefer $(element).removeData(). Learn the static form so you can read utility demos and work when you already hold a raw element. See the Utilities hub and jQuery.data().
Concept
Understanding the jQuery.removeData() Method
Pass a DOM element first. Optionally pass a string name for the key to delete. Omit name to wipe the whole store for that element.
Only the internal jQuery cache is affected. HTML data-* attributes are left alone unless you also call .removeAttr().
💡
Beginner Tip
Think of jQuery.removeData(el, "foo") as erasing one sticky note on the element. Prefer $(el).removeData("foo") when you are already in jQuery chaining land.
Foundation
📝 Syntax
Signature (jQuery 1.2.3+):
jQuery
jQuery.removeData( element [, name ] )
Parameters
element (Element) — DOM node whose data should be cleared.
name (String, optional) — key to remove. Omit to remove all stored values for the element.
Return value
undefined — not chainable like .removeData().
Official pattern
jQuery
var div = $( "div" )[ 0 ];
jQuery.data( div, "test1", "VALUE-1" );
jQuery.data( div, "test2", "VALUE-2" );
jQuery.removeData( div, "test1" );
// test1 gone; test2 still "VALUE-2"
Cheat Sheet
⚡ Quick Reference
Goal
Code
Remove one key
jQuery.removeData( el, "test1" )
Clear all keys
jQuery.removeData( el )
Preferred instance API
$( el ).removeData( "test1" )
Also drop attribute
$( el ).removeAttr( "data-test1" )
Input
Element
Raw DOM node required
Optional
name
Key to delete
Returns
undefined
No chaining from static call
Prefer
.removeData()
Instance method for apps
Compare
📋 jQuery.removeData() vs .removeData() vs .removeAttr()
jQuery.removeData(el)
$(el).removeData()
.removeAttr("data-…")
Target
jQuery cache
jQuery cache
HTML attribute
Input
DOM element
jQuery collection
jQuery collection
Best for
Low-level / demos
Everyday cleanup
Markup cleanup
Hands-On
Examples Gallery
Examples follow the official jQuery API demo and practical cleanup patterns.
📚 Getting Started
Remove one key after storing two — the official pattern.
var el = document.getElementById( "box" );
jQuery.data( el, "a", 1 );
jQuery.data( el, "b", 2 );
jQuery.removeData( el );
console.log( jQuery.data( el ) ); // {} (or empty store)
jQuery.removeData() has been part of jQuery since 1.2.3+. It works in every browser supported by your jQuery build — including modern evergreen browsers with jQuery 3.x.
✓ jQuery 1.2.3+
jQuery.removeData()
Stable low-level data cleanup utility. Prefer .removeData() on collections for everyday code.
100%With jQuery 1.2.3+
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
jQuery.removeData1.2.3+
Bottom line: Use to clear jQuery’s cache on a raw element; use .removeData() when chaining.
Wrap Up
Conclusion
jQuery.removeData() deletes cached values for a DOM element — one key or all of them. It is the low-level twin of .removeData(). Prefer the instance method in app code; use the static form with raw nodes and utility demos.
jQuery.removeData(element [, name]) deletes previously stored jQuery data from a DOM element. With a name, only that key is removed. With no name, all values for that element are removed. It returns undefined. Added in jQuery 1.2.3. Prefer $(element).removeData() for everyday code.
Same cache, different call shape. jQuery.removeData(el, key) takes a raw DOM element. .removeData() is called on a jQuery collection and is chainable. Official docs recommend .removeData(); this static method is the low-level twin used in utilities and older samples.
No. It only clears jQuery’s internal cache. Attributes like data-test1 stay in the markup. A later $(el).data("test1") may re-read the attribute into the cache. Use .removeAttr("data-test1") as well when you need the attribute gone.
jQuery.removeData(element) with no name clears the entire data store for that element (all keys you set with jQuery.data / .data that live in the cache).
The API returns undefined. Unlike .removeData(), you cannot chain further jQuery methods off the static call.
When you already hold a raw DOM node (for example div = $("div")[0]) or are following official utility demos that pair jQuery.data with jQuery.removeData. New UI code should prefer .removeData() on a collection.
Did you know?
The official jQuery.removeData demo uses both $("div").data() and jQuery.data(div, …) in the same snippet — a reminder that the collection and static APIs share one cache, even when demos mix call styles.