Used by the dataset HTML attribute to represent data for custom attributes added to elements. 

方法预览

DOMString getDataAttr(in DOMString prop);
boolean hasDataAttr(in DOMString prop);
void removeDataAttr(in DOMString prop);
void removeProp(in nsIAtom attr);
void setDataAttr(in DOMString prop, in DOMString value);

方法

hasDataAttr()

boolean hasDataAttr(
  in DOMString prop
);
参数
prop
属性名
返回值

  如果该属性存在则返回 true,否则返回 false

removeDataAttr()

void removeDataAttr(
  in DOMString prop
);
参数
prop
属性名

removeProp()

移除属性,当移除的是 data-* 属性时更新整个数据集

void removeProp(
  in nsIAtom attr
);
参数
attr
属性名

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support ? 6.0 (6.0) ? ? ?
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

参见

文档标签和贡献者

此页面的贡献者: wbamberg, mdnwebdocs-bot, ShiJianwen, lann1986, FredWe
最后编辑者: wbamberg,