{"name":"jQuery.removeData","type":"method","title":"jQuery.removeData()","deprecated":null,"removed":null,"desc":"Remove a previously-stored piece of data.","categories":["data","utilities","version/1.2.3"],"entries":[{"return":"jQuery","signatures":{"added":"1.2.3","argument":[{"desc":"A DOM element from which to remove data.","name":"element","type":"Element"},{"desc":"A string naming the piece of data to remove.","name":"name","type":"String","optional":"true"}]},"examples":{"desc":"Set a data store for 2 names then remove one of them.","code":"\nvar div = $( \"div\" )[ 0 ];\n$( \"span:eq(0)\" ).text( \"\" + $( \"div\" ).data( \"test1\" ) );\njQuery.data( div, \"test1\", \"VALUE-1\" );\njQuery.data( div, \"test2\", \"VALUE-2\" );\n$( \"span:eq(1)\" ).text( \"\" + jQuery.data( div, \"test1\" ) );\njQuery.removeData( div, \"test1\" );\n$( \"span:eq(2)\" ).text( \"\" + jQuery.data( div, \"test1\" ) );\n$( \"span:eq(3)\" ).text( \"\" + jQuery.data( div, \"test2\" ) );\n","css":"\n div {\n margin: 2px;\n color: blue;\n }\n span {\n color: red;\n }\n","html":"\n
Note: This is a low-level method, you should probably use .removeData() instead.
The jQuery.removeData() method allows us to remove values that were previously set using jQuery.data(). When called with the name of a key, jQuery.removeData() deletes that particular value; when called with no arguments, all values are removed.