aboutsummaryrefslogtreecommitdiff
path: root/files/it/web/api/element/removeattribute/index.html
blob: 2a64205cc361bb16697bb696d5c4ccd641503604 (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
---
title: Element.removeAttribute()
slug: Web/API/Element/removeAttribute
tags:
  - API
  - DOM
  - Elemento
  - Riferimento
  - metodo
translation_of: Web/API/Element/removeAttribute
---
<div>{{ APIRef("DOM") }}</div>

<p><span class="seoSummary">Il metodo {{domxref("Element")}} <strong><code>removeAttribute()</code></strong> rimuove l'attributo con il nome specificato dall'elemento.</span></p>

<h2 id="Sintassi">Sintassi</h2>

<pre class="syntaxbox"><em>element</em>.removeAttribute(<em>attrName</em>);
</pre>

<h3 id="Parametri">Parametri</h3>

<dl>
 <dt><code>attrName</code></dt>
 <dd>Una {{domxref("DOMString")}} che specifica il nome dell'attributo da rimuovere dall'elemento. Se l'attributo specificato non esiste, <code>removeAttribute()</code> restituisce senza generare un errore.</dd>
</dl>

<h3 id="Valore_di_ritorno">Valore di ritorno</h3>

<p><code>undefined</code>.</p>

<div class="note">
<p><strong>Note:</strong> Poiché <code>removeAttribute()</code> non restituisce un valore, non è possibile concatenare più chiamate contemporaneamente per rimuovere più attributi contemporaneamente.</p>
</div>

<h2 id="Note_di_utilizzo">Note di utilizzo</h2>

<p>Dovresti usare <code>removeAttribute()</code> <font><font>invece di impostare il valore dell'attributo </font></font><code>null</code> <font><font>direttamente o usando</font></font> {{domxref("Element.setAttribute", "setAttribute()")}}. Molti attributi non si comportano come previsto se li imposti a <code>null</code>.</p>

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

<h2 id="Esempio">Esempio</h2>

<pre class="brush: js">// Prima: &lt;div id="div1" align="left" width="200px"&gt;
document.getElementById("div1").removeAttribute("align");
// Dopo: &lt;div id="div1" width="200px"&gt;
</pre>

<h2 id="Specifica">Specifica</h2>

<p><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-6D6AC0F9">DOM Level 2 Core: removeAttribute</a> (introdotta nel <a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#method-removeAttribute">DOM Level 1 Core</a>)</p>

<h2 id="Compatibilità_con_i_browser">Compatibilità con i browser</h2>



<p>{{Compat("api.Element.removeAttribute")}}</p>