removeData()
功能
删除先前存储的数据。
语法
datax.removeData(elm, name)
参数
- elm
HTMLElement对象,指定对象HTML元素 - name
将数据块命名为删除的字符串
范例
Example: 设置数据,然后再删除。
<!DOCTYPE html> <html> <head> <style> div { margin: 2px;color: blue; } span { color: red;} </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <div>value1 after creation: <span></span></div> <div>value1 after removal: <span></span></div> <script> require(["skylark/query", "skylark/finder", "skylark/datax"], function(query, finder, datax) { var div = query("div")[0]; datax.data(div, "test1", "VALUE-1"); query("span:first").text("" + datax.data(div, "test1")); datax.removeData(div, "test1") query("span:last").text("" + datax.data(div, "test1")); }); </script> </body> </html>