aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/node/contains/index.html
blob: 0441a931d951e9c6556a9793759e8ee155acdd62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
title: Node.contains
slug: Web/API/Node/contains
translation_of: Web/API/Node/contains
---
<div>
<div>{{ApiRef("DOM")}}</div>
</div>

<h2 id="Summary" name="Summary">Sumário</h2>

<p>Indica se um nó é um descendente de um dado nó.</p>

<h2 id="Syntax" name="Syntax">Sintaxe</h2>

<pre class="syntaxbox">node.contains( otherNode )
</pre>

<ul>
 <li><code>node</code> é o nó que está sendo comparado.</li>
 <li><code>otherNode</code> é o nó contra o qual está sendo comparado.</li>
</ul>

<p>O valor de retorno é <code>true</code> se <code>otherNode</code> é um descendente de um nó ou o próprio nó. Caso contrário o valor de retorno é <code>false</code>.</p>

<h2 id="Example" name="Example">Exemplo</h2>

<p>Esta função verifica se um elemento está no corpo da página. As <code>contains</code> is inclusive and determining if the body contains itself isn't the intention of <code>isInPage</code> this case explicitly returns <code>false</code>.</p>

<pre class="brush:js">function isInPage(node) {
  return (node === document.body) ? false : document.body.contains(node);
}</pre>

<ul>
 <li><code>node</code> é o nó <span id="result_box" lang="pt"><span class="hps">que</span> <span class="hps">desejamos verificar</span> se está <span class="hps">no</span> </span><code>&lt;body&gt;</code>.</li>
</ul>

<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>

<p>{{CompatibilityTable}}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoDesktop("9.0")}}</td>
   <td>5.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>5.2.2 <a href="https://code.google.com/p/doctype-mirror/wiki/ArticleNodeContains" title="https://code.google.com/p/doctype-mirror/wiki/ArticleNodeContains">[1]</a><a href="https://github.com/okfn/annotator/blob/master/src/range.coffee#L366">[2]</a></td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Recurso</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Suporte básico</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatGeckoMobile("9.0")}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="Specification" name="Specification">Especificação</h2>

<ul>
 <li><a class="external" href="http://www.w3.org/TR/domcore/#dom-node-contains">DOM Level 4: contains</a></li>
</ul>

<h2 id="See_also" name="See_also">Ver também</h2>

<ul>
 <li>{{domxref("Node.hasChildNodes")}}</li>
</ul>