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 742757 of DOMStringMap

  • Revision slug: Web/API/DOMStringMap
  • Revision title: DOMStringMap
  • Revision id: 742757
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment Mountain View APIRef Project

Revision Content

{{ APIRef("HTML DOM") }}

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.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} {{ CompatGeckoDesktop("6.0") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

See also

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

Revision Source

<p>{{ APIRef("HTML DOM") }}</p>

<p>Used by the {{ htmlattrxref("dataset") }}&nbsp;HTML&nbsp;attribute to represent data for custom attributes added to elements.</p>

<h2 id="Method_overview" 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 id="Methods" name="Methods">Methods</h2>

<p>{{ method_noscript("getDataAttr") }}</p>

<pre class="eval">
DOMString getDataAttr(
  in DOMString prop
);
</pre>

<h6 id="Parameters" name="Parameters">Parameters</h6>

<dl>
 <dt><code>prop</code></dt>
 <dd>The property for which to retrieve the value.</dd>
</dl>

<h6 id="Return_value" 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 id="Parameters" 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 id="Return_value" 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 id="Parameters" 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 id="Parameters" 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 id="Parameters" 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 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatGeckoDesktop("6.0") }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
   <td>{{ CompatUnknown() }}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>{{ domxref("element.dataset") }}</li>
 <li>{{ htmlattrxref("dataset") }}</li>
</ul>
Revert to this revision