aboutsummaryrefslogtreecommitdiff
path: root/files/pt-br/web/api/htmlelement/blur/index.html
blob: 25a2273aec67c5dd44360b5a992944a472a964fc (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
---
title: HTMLElement.blur()
slug: Web/API/HTMLElement/blur
tags:
  - API
  - DOM HTML
  - Foco
  - HTMLElement
  - Referencia
  - metodo
translation_of: Web/API/HTMLOrForeignElement/blur
---
<div>{{ APIRef("HTML DOM") }}</div>

<p>O método <code><strong>HTMLElement.blur()</strong></code> remove o foco do teclado no elemento corrente.</p>

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

<pre class="syntaxbox"><em>elemento</em>.blur();</pre>

<h2 id="Exemplos">Exemplos</h2>

<h3 id="Removendo_o_foco_de_um_input_de_texto">Removendo o foco de um input de texto</h3>

<h4 id="HTML">HTML</h4>

<pre class="brush: html">&lt;input type="text" id="meuTexto" value="Texto Exemplo"&gt;
&lt;br&gt;&lt;br&gt;
&lt;button type="button" onclick="focusInput()"&gt;Clique para definir o foco&lt;/button&gt;
&lt;button type="button" onclick="blurInput()"&gt;Clique para remover o foco&lt;/button&gt;</pre>

<h4 id="JavaScript">JavaScript</h4>

<pre class="brush: js">function focusInput() {
  document.getElementById('meuTexto').focus();
}
function blurInput() {
  document.getElementById('meuTexto').blur();
}</pre>

<h4 id="Resultado">Resultado</h4>

<p>{{ EmbedLiveSample('Remove_focus_from_a_text_input') }}</p>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Especificação</th>
   <th scope="col">Status</th>
   <th scope="col">Comentário</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'editing.html#dom-blur', 'blur')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1', 'editing.html#blur()-0', 'blur')}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'editing.html#dom-blur', 'blur')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td> </td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 HTML', 'html.html#ID-28216144', 'blur')}}</td>
   <td>{{Spec2('DOM2 HTML')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilidade_com_navegadores">Compatibilidade com navegadores</h2>



<p>{{Compat("api.HTMLElement.blur")}}</p>

<h2 id="Veja_também">Veja também</h2>

<ul>
 <li>Método DOM {{domxref("HTMLElement.focus()")}}</li>
</ul>