aboutsummaryrefslogtreecommitdiff
path: root/files/ko/web/api/domtokenlist/contains/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ko/web/api/domtokenlist/contains/index.html')
-rw-r--r--files/ko/web/api/domtokenlist/contains/index.html117
1 files changed, 117 insertions, 0 deletions
diff --git a/files/ko/web/api/domtokenlist/contains/index.html b/files/ko/web/api/domtokenlist/contains/index.html
new file mode 100644
index 0000000000..5913cdf749
--- /dev/null
+++ b/files/ko/web/api/domtokenlist/contains/index.html
@@ -0,0 +1,117 @@
+---
+title: DOMTokenList.contains()
+slug: Web/API/DOMTokenList/contains
+translation_of: Web/API/DOMTokenList/contains
+---
+<p>{{APIRef("DOM")}}</p>
+
+<p>The <code><strong>contains()</strong></code> method of the {{domxref("DOMTokenList")}} interface returns a {{domxref("Boolean")}} — <code>true</code> if the underlying list contains the given <em>token</em>, otherwise <code>false</code>.</p>
+
+<h2 id="Syntax">Syntax</h2>
+
+<pre class="syntaxbox">tokenList.contains(token);</pre>
+
+<h3 id="Parameters">Parameters</h3>
+
+<dl>
+ <dt>token</dt>
+ <dd>A {{domxref("DOMString")}} representing the token you want to check for the existance of in the list.</dd>
+</dl>
+
+<h3 id="Return_value">Return value</h3>
+
+<p>A {{domxref("Boolean")}} — <code>true</code> if the underlying list contains the given <em>token</em>, otherwise <code>false</code>.</p>
+
+<h2 id="Examples">Examples</h2>
+
+<p>In the following example we retrieve the list of classes set on a {{htmlelement("span")}} element as a <code>DOMTokenList</code> using {{domxref("Element.classList")}}. We then test for the existance of "c" in the list, and write the result into the <code>&lt;span&gt;</code>'s {{domxref("Node.textContent")}}.</p>
+
+<p>First, the HTML:</p>
+
+<pre class="brush: html">&lt;span class="a b c"&gt;&lt;/span&gt;</pre>
+
+<p>Now the JavaScript:</p>
+
+<pre class="brush: js">var span = document.querySelector("span");
+var classes = span.classList;
+var result = classes.contains("c");
+if(result) {
+ span.textContent = "The classList contains 'c'";
+} else {
+ span.textContent = "The classList does not contain 'c'";
+}</pre>
+
+<p>The output looks like this:</p>
+
+<p>{{ EmbedLiveSample('Examples', '100%', 60) }}</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM WHATWG','#dom-domtokenlist-contains','contains()')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Initial definition</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<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 (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>10</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Android Webview</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatVersionUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p> </p>