很多同学在项目中都喜欢将数据存储在HTMLElement属性上,如 代码如下: Test [removed] div.getAttribute(‘data’); // some data [removed] 给页面中div添加了自定义属性“data”及值“some data”。后续JS代码中使用getAttribute获取。 jQuery从1.2.3开始提供了data/removeData方法用来存储/删除数据。1.6.1代码片段 代码如下: jQuery.extend({ cache: {}, // Please use with