Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 84921 of DOMStringMap

  • Revision slug: DOM/DOMStringMap
  • Revision title: DOMStringMap
  • Revision id: 84921
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment new page for bug 560112; page created, 204 words added

Revision Content

{{ draft() }}

Used by the {{ htmlattrxref("dataset") }} HTML attribute to represent data for custom attributes added to elements.

Method overview

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

Methods

{{ method_noscript("getDataAttr") }}

DOMString getDataAttr(
  in DOMString prop
);
Parameters
prop
The property for which to retrieve the value.
Return value

The value for the specified property name.

{{ method_notxpcom("hasDataAttr") }}

boolean hasDataAttr(
  in DOMString prop
);
Parameters
prop
The property for which to check for the existence of a value.
Return value

true if the property exists; otherwise false.

{{ method_notxpcom("removeDataAttr") }}

void removeDataAttr(
  in DOMString prop
);
Parameters
prop
The property to remove from the data set.

{{ method_notxpcom("removeProp") }}

Removes the property from the dataset object. Used to update the dataset object when data-* attribute has been removed from the element.

void removeProp(
  in nsIAtom attr
);
Parameters
attr
The property to remove from the dataset.

{{ method_noscript("setDataAttr") }}

Sets the value of the specified property.

void setDataAttr(
  in DOMString prop,
  in DOMString value
);
Parameters
prop
The property whose value is to be set.
value
The property's new value.

See also

  • {{ domxref("element.dataset") }}
  • {{ htmlattrxref("dataset") }}

Revision Source

<p>{{ draft() }}</p>
<p>Used by the {{ htmlattrxref("dataset") }} HTML attribute to represent data for custom attributes added to elements.</p>
<h2 name="Method_overview">Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>DOMString <a href="#getDataAttr()">getDataAttr</a>(in DOMString prop);</code> {{ noscript_inline() }}</td> </tr> <tr> <td><code>boolean <a href="#hasDataAttr()">hasDataAttr</a>(in DOMString prop);</code> {{ notxpcom_inline() }}</td> </tr> <tr> <td><code>void <a href="#removeDataAttr()">removeDataAttr</a>(in DOMString prop);</code> {{ notxpcom_inline() }}</td> </tr> <tr> <td><code>void <a href="#removeProp()">removeProp</a>(in nsIAtom attr);</code> {{ notxpcom_inline() }}</td> </tr> <tr> <td><code>void <a href="#setDataAttr()">setDataAttr</a>(in DOMString prop, in DOMString value);</code> {{ noscript_inline() }}</td> </tr> </tbody>
</table>
<h2 name="Methods">Methods</h2>
<p>{{ method_noscript("getDataAttr") }}</p>
<pre class="eval">DOMString getDataAttr(
  in DOMString prop
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>prop</code></dt> <dd>The property for which to retrieve the value.</dd>
</dl>
<h6 name="Return_value">Return value</h6>
<p>The value for the specified property name.</p>
<p>{{ method_notxpcom("hasDataAttr") }}</p>
<pre class="eval">boolean hasDataAttr(
  in DOMString prop
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>prop</code></dt> <dd>The property for which to check for the existence of a value.</dd>
</dl>
<h6 name="Return_value">Return value</h6>
<p><code>true</code> if the property exists; otherwise <code>false</code>.</p>
<p>{{ method_notxpcom("removeDataAttr") }}</p>
<pre class="eval">void removeDataAttr(
  in DOMString prop
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>prop</code></dt> <dd>The property to remove from the data set.</dd>
</dl>
<p>{{ method_notxpcom("removeProp") }}</p>
<p>Removes the property from the dataset object. Used to update the dataset object when data-* attribute has been removed from the element.</p>
<pre class="eval">void removeProp(
  in nsIAtom attr
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>attr</code></dt> <dd>The property to remove from the dataset.</dd>
</dl>
<p>{{ method_noscript("setDataAttr") }}</p>
<p>Sets the value of the specified property.</p>
<pre class="eval">void setDataAttr(
  in DOMString prop,
  in DOMString value
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>prop</code></dt> <dd>The property whose value is to be set.</dd> <dt><code>value</code></dt> <dd>The property's new value.</dd>
</dl>
<h2>See also</h2>
<ul> <li>{{ domxref("element.dataset") }}</li> <li>{{ htmlattrxref("dataset") }}</li>
</ul>
Revert to this revision