3 ms·
I hade my gripes with .data too: <div id="test" data-foo="bar"></div> <script> $("#test").removeData('foo'); console.log("#test").data('foo'));
by voidr 15y ago
I hade my gripes with .data too:
<div id="test" data-foo="bar"></div>
<script>
$("#test").removeData('foo');
console.log("#test").data('foo'));
//bar
</script>
The thing is removeData is pretty much useless because it only removes data from the jQuery cache, but if the data is missing from the cache jQuery will look in the DOM anyway.