Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以获取存储在元素上的数据数量然后遍历它们?
例如,我想做类似的事情:
for(;elmt.data().length<i++;){ //iterate thro elmt.data }
.data()返回一个没有属性的对象length,但这会起作用:
.data()
length
$.each($('#someElement').data(), function (key, value) { console.log(key,value); });