--- 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><span></code>'s {{domxref("Node.textContent")}}.</p> <p>First, the HTML:</p> <pre class="brush: html"><span class="a b c"></span></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> <p>{{Compat("api.DOMTokenList.contains")}}</p>