mozilla

Revision 169801 of element

  • Slug da revisão: DOM/element
  • Título da revisão: element
  • ID da revisão: 169801
  • Criado:
  • Autor: Davis.peixoto
  • É revisão atual? Não
  • Comentário

Conteúdo da revisão

{{template.DomRef()}}

Este capítulo dispõe uma breve referência para métodos, propriedades, e eventos em geral disponíveis para a maioria dos elementos HTML e XML no DOM Gecko.

Várias especificações W3C se aplicam aos elementos:

  • DOM Core Specification—descreve as interfaces centrais compartilhadas pela maioria dos objetos DOM em documentos HTML e XML
  • DOM HTML Specification—descreve interfaces para objetos nos documentos HTML e XHTML que foram contruídas com base nas especificações centrais
  • DOM Events Specification—descreve eventos compartilhados pela maioria dos objetos DOM, contruídas com base nas especificações DOM Core e Views

Os artigos listados aqui abrangem as especificações acima, bem como incluem links para as especificações W3C apropriadas.

Enquanto estas interfaces são geralmente compartilhadas pela maioria dos elementos HTML e XML, existem interfaces mais especializadas para objetos particulares listados na especificação do DOM HTML—por exemplo, as interfaces HTML Table Element e HTML Form Element

Propriedades

</tr>
Nome Descrição Tipo Dosponibilidade
attibutes Todos os atributos associados ao elemento NamedNodeMap All
childNodes Todos os nós-filhos de um elemento. NodeList All
className Retorna ou define a classe do elemento. String HTML, XUL
clientHeight A altura interna de um elemento. Number HTML
clientLeft A largura da borda esquerda de um elemento. Number HTML
clientTop A largura da borda superior de um elemento. Number HTML
clientWidth A largura interna de um elemento. Number HTML
dir Retorna ou define a direcionalidade do elemento. String HTML, XUL
firstChild O primeiro nó-filho direto de um elemento, ou null se o elemento não tem nós-filhos. Node All
id Retorna ou define o id do elemento. String HTML, XUL
innerHTML Retorna ou define a marcação e o conteúdo de um elemento. String HTML
lang Retorna ou define o atributo linguagem de um elemento, texto, e conteúdo do elemento. String HTML
lastChild O último nó-filho direto de um elemento, ou null se o elemento não tem nós-filhos. Node All
localName A parte local de um nome qualificado de um elemento. String All
Nome Descrição Tipo Disponibilidade
name Retorna/define o atributo name de um elemento. String HTML
namespaceURI A URI de namespace do nó, ou null se não está especificado. String All
nextSibling O nó imediatamente seguinte ao dado numa árvore, ou null se não existe nó-irmão. Node All
nodeName O nome do nó. String All
nodeType Um número representando o tipo do nó. É sempre igual a 1 para elementos DOM. Number All
nodeValue O valor do nó. É sempre igual a null para elementos DOM. String All
offsetHeight A altura de um elemento, em relação ao layout. Number HTML
offsetLeft A distância da borda esquerda do elemento para o a borda esquerda do seu offsetParent. Number HTML
offsetParent O elemento para o qual todos cálculos de offset estão atualmente computados. Element HTML
offsetTop A distância da borda superior do elemento para o a borda superior do seu offsetParent. Number HTML
offsetWidth A largura de um elemento, em relação ao layout. Number HTML
ownerDocument O documento no qual o nó está, ou null se o nó não está dentro de nenhum. Document All
Name Description Type Availability
parentNode The parent element of this node, or null if the node is not inside of a DOM Document. Node All
prefix The namespace prefix of the node, or null if no prefix is specified. String All
previousSibling The node immediately preceding the given one in the tree, or null if there is no sibling node. Node All
scrollHeight The scroll view height of an element. Number HTML
scrollLeft Gets/sets the left scroll offset of an element. Number HTML
scrollTop Gets/sets the top scroll offset of an element. Number HTML
scrollWidth The scroll view width of an element. Number HTML
style An object representing the declarations of an element's style attributes. CSSStyle HTML, XUL
tabIndex Gets/sets the position of the element in the tabbing order. Number HTML
tagName The name of the tag for the given element. String All
textContent Gets/sets the textual contents of an element and all its descendants. String All

Methods

Name & Description Return Availability
addEventListener( type, listener, useCapture )
Register an event handler to a specific event type on the element.
- All
appendChild( appendedNode )
Insert a node as the last child node of this element.
Node All
blur()
Removes keyboard focus from the current element.
- HTML, XUL
click()
Simulates a click on the current element.
- HTML, XUL
cloneNode( deep )
Clone a node, and optionally, all of its contents.
Node All
dispatchEvent( event )
Dispatch an event to this node in the DOM.
Boolean All
focus()
Gives keyboard focus to the current element.
- HTML, XUL
getAttribute( name )
Retrieve the value of the named attribute from the current node.
Object All
getAttributeNS( namespace, name )
Retrieve the value of the attribute with the specified name and namespace, from the current node.
Object All
getAttributeNode( name )
Retrieve the node representation of the named attribute from the current node.
Attr All
getAttributeNodeNS( namespace, name )
Retrieve the node representation of the attribute with the specified name and namespace, from the current node.
Attr All
Name & Description Return Availability
getElementsByTagName( name )
Retrieve a set of all descendant elements, of a particular tag name, from the current element.
NodeSet All
getElementsByTagNameNS( namespace, name )
Retrieve a set of all descendant elements, of a particular tag name and namespace, from the current element.
NodeSet All
hasAttribute( name )
Check if the element has the specified attribute, or not.
Boolean All
hasAttributeNS( namespace, name )
Check if the element has the specified attribute, in the specified namespace, or not.
Boolean All
hasAttributes()
Check if the element has any attributes, or not.
Boolean All
hasChildNodes()
Check if the element has any child nodes, or not.
Boolean All
insertBefore( insertedNode, adjacentNode )
Inserts the first node before the second, child, Node in the DOM.
Node All
normalize()
Clean up all the text nodes under this element (merge adjacent, remove empty).
- All
removeAttribute( name )
Remove the named attribute from the current node.
- All
removeAttributeNS( namespace, name )
Remove the attribute with the specified name and namespace, from the current node.
- All
Name & Description Return Availability
removeAttributeNode( name )
Remove the node representation of the named attribute from the current node.
- All
removeChild( removedNode )
Removes a child node from the current element.
Node All
removeEventListener( type, handler, useCapture )
Removes an event listener from the element.
- All
replaceChild( insertedNode, replacedNode )
Replaces one child node in the current element with another.
Node All
scrollIntoView( alignWithTop )
Scrolls the page until the element gets into the view.
- HTML
setAttribute( name, value )
Set the value of the named attribute from the current node.
- All
setAttributeNS( namespace, name, value )
Set the value of the attribute with the specified name and namespace, from the current node.
- All
setAttributeNode( name, attrNode )
Set the node representation of the named attribute from the current node.
- All
setAttributeNodeNS( namespace, name, attrNode )
Set the node representation of the attribute with the specified name and namespace, from the current node.
- All

Event Handlers

These are properties that correspond to the HTML 'on' event attributes.

Unlike the corresponding attributes, the values of these properties are functions (or any other object implementing the EventListener interface) rather than a string. In fact, assigning an event attribute in HTML creates a wrapper function around the specified code. For example, given the following HTML:

<div onclick="foo();">click me!</div>

If element is a reference to this div, the value of element.onclick is effectively:

function onclick(event) {
   foo();
}

Note how the event object is passed as parameter event to this wrapper function.

onblur
Returns the event handling code for the blur event.
onchange
Returns the event handling code for the change event.
onclick
Returns the event handling code for the click event.
ondblclick
Returns the event handling code for the dblclick event.
onfocus
Returns the event handling code for the focus event.
onkeydown
Returns the event handling code for the keydown event.
onkeypress
Returns the event handling code for the keypress event.
onkeyup
Returns the event handling code for the keyup event.
onmousedown
Returns the event handling code for the mousedown event.
onmousemove
Returns the event handling code for the mousemove event.
onmouseout
Returns the event handling code for the mouseout event.
onmouseover
Returns the event handling code for the mouseover event.
onmouseup
Returns the event handling code for the mouseup event.
onresize
Returns the event handling code for the resize event.
onscroll
Returns the event handling code for the scroll event.
{{ wiki.languages( { "es": "es/DOM/element", "fr": "fr/DOM/element", "ja": "ja/DOM/element", "pl": "pl/DOM/element", "en": "en/DOM/element", "zh-cn": "cn/DOM/element" } ) }}

Fonte da revisão

<p>
{{template.DomRef()}}
</p><p>Este capítulo dispõe uma breve referência para métodos, propriedades, e eventos em geral disponíveis para a maioria dos elementos HTML e XML no DOM Gecko.
</p><p>Várias especificações W3C se aplicam aos elementos:
</p>
<ul><li> <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/">DOM Core Specification</a>—descreve as interfaces centrais compartilhadas pela maioria dos objetos DOM em documentos HTML e XML
</li><li> <a class="external" href="http://www.w3.org/TR/DOM-Level-2-HTML/">DOM HTML Specification</a>—descreve interfaces para objetos nos documentos HTML e XHTML que foram contruídas com base nas especificações centrais
</li><li> <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/">DOM Events Specification</a>—descreve eventos compartilhados pela maioria dos objetos DOM, contruídas com base nas especificações DOM Core e <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Views/">Views</a>
</li></ul>
<p>Os artigos listados aqui abrangem as especificações acima, bem como incluem links para as especificações W3C apropriadas.
</p><p>Enquanto estas interfaces são geralmente compartilhadas pela maioria dos elementos HTML e XML, existem interfaces mais especializadas para objetos particulares listados na especificação do DOM HTML—por exemplo, as interfaces <a href="pt/DOM/table">HTML Table Element</a> e <a href="pt/DOM/form">HTML Form Element</a>
</p>
<h3 name="Propriedades"> Propriedades </h3>

&lt;/tr&gt;
<table class="fullwidth-table">
<tbody><tr>
<th>Nome</th>
<th>Descrição</th>
<th>Tipo</th>
<th>Dosponibilidade</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.attributes">attibutes</a></code></td>
<td>Todos os atributos associados ao elemento</td>
<td><code><a href="pt/DOM/NamedNodeMap">NamedNodeMap</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.childNodes">childNodes</a></code></td>
<td>Todos os nós-filhos de um elemento.</td>
<td><code><a href="pt/DOM/NodeList">NodeList</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.className">className</a></code></td>
<td>Retorna ou define a classe do elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.clientHeight">clientHeight</a></code></td>
<td>A altura interna de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.clientLeft">clientLeft</a></code></td>
<td>A largura da borda esquerda de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.clientTop">clientTop</a></code></td>
<td>A largura da borda superior de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.clientWidth">clientWidth</a></code></td>
<td>A largura interna de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.dir">dir</a></code></td>
<td>Retorna ou define a direcionalidade do elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.firstChild">firstChild</a></code></td>
<td>O primeiro nó-filho direto de um elemento, ou <code>null</code> se o elemento não tem nós-filhos.</td>
<td><code><a href="pt/DOM/Node">Node</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.id">id</a></code></td>
<td>Retorna ou define o id do elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.innerHTML">innerHTML</a></code></td>
<td>Retorna ou define a marcação e o conteúdo de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.lang">lang</a></code></td>
<td>Retorna ou define o atributo linguagem de um elemento, texto, e conteúdo do elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.lastChild">lastChild</a></code></td>
<td>O último nó-filho direto de um elemento, ou <code>null</code> se o elemento não tem nós-filhos.</td>
<td><code><a href="pt/DOM/Node">Node</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.localName">localName</a></code></td>
<td>A parte local de um nome qualificado de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<th>Nome</th>
<th>Descrição</th>
<th>Tipo</th>
<th>Disponibilidade</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.name">name</a></code></td>
<td>Retorna/define o atributo name de um elemento.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.namespaceURI">namespaceURI</a></code></td>
<td>A URI de namespace do nó, ou <code>null</code> se não está especificado.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.nextSibling">nextSibling</a></code></td>
<td>O nó imediatamente seguinte ao dado numa árvore, ou <code>null</code> se não existe nó-irmão.</td>
<td><code><a href="pt/DOM/Node">Node</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.nodeName">nodeName</a></code></td>
<td>O nome do nó.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr><tr>
<td><code><a href="pt/DOM/element.nodeType">nodeType</a></code></td>
<td>Um número representando o tipo do nó. É sempre igual a <code>1</code> para elementos DOM.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.nodeValue">nodeValue</a></code></td>
<td>O valor do nó. É sempre igual a <code>null</code> para elementos DOM.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.offsetHeight">offsetHeight</a></code></td>
<td>A altura de um elemento, em relação ao layout.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.offsetLeft">offsetLeft</a></code></td>
<td>A distância da borda esquerda do elemento para o a borda esquerda do seu <code>offsetParent</code>.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.offsetParent">offsetParent</a></code></td>
<td>O elemento para o qual todos cálculos de offset estão atualmente computados.</td>
<td><code><a href="pt/DOM/element">Element</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.offsetTop">offsetTop</a></code></td>
<td>A distância da borda superior do elemento para o a borda superior do seu <code>offsetParent</code>.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.offsetWidth">offsetWidth</a></code></td>
<td>A largura de um elemento, em relação ao layout.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.ownerDocument">ownerDocument</a></code></td>
<td>O documento no qual o nó está, ou <code>null</code> se o nó não está dentro de nenhum.</td>
<td><code><a href="pt/DOM/document">Document</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<th>Name</th>
<th>Description</th>
<th>Type</th>
<th>Availability</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.parentNode">parentNode</a></code></td>
<td>The parent element of this node, or <code>null</code> if the node is not inside of a <a href="pt/DOM/document">DOM Document</a>.</td>
<td><code><a href="pt/DOM/Node">Node</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.prefix">prefix</a></code></td>
<td>The namespace prefix of the node, or <code>null</code> if no prefix is specified.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.previousSibling">previousSibling</a></code></td>
<td>The node immediately preceding the given one in the tree, or <code>null</code> if there is no sibling node.</td>
<td><code><a href="pt/DOM/Node">Node</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.scrollHeight">scrollHeight</a></code></td>
<td>The scroll view height of an element.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.scrollLeft">scrollLeft</a></code></td>
<td>Gets/sets the left scroll offset of an element.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.scrollTop">scrollTop</a></code></td>
<td>Gets/sets the top scroll offset of an element.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.scrollWidth">scrollWidth</a></code></td>
<td>The scroll view width of an element.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.style">style</a></code></td>
<td>An object representing the declarations of an element's style attributes.</td>
<td><code><a href="pt/DOM/CSSStyleDeclaration">CSSStyle</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.tabIndex">tabIndex</a></code></td>
<td>Gets/sets the position of the element in the tabbing order.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Number">Number</a></code></td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.tagName">tagName</a></code></td>
<td>The name of the tag for the given element.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.textContent">textContent</a></code></td>
<td>Gets/sets the textual contents of an element and all its descendants.</td>
<td><code><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">String</a></code></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
</tbody></table>
<h3 name="Methods"> Methods </h3>
<table class="fullwidth-table">
<tbody><tr>
<th>Name &amp; Description</th>
<th>Return</th>
<th>Availability</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.addEventListener">addEventListener</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">type</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Function">listener</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">useCapture</a> )</code><br>
Register an event handler to a specific event type on the element.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM/event">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.appendChild">appendChild</a>( <a href="pt/DOM/Node">appendedNode</a> )</code><br>
Insert a node as the last child node of this element.</td>
<td><a href="pt/DOM/Node">Node</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.blur">blur</a>()</code><br>
Removes keyboard focus from the current element.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.click">click</a>()</code><br>
Simulates a click on the current element.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.cloneNode">cloneNode</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">deep</a> )</code><br>
Clone a node, and optionally, all of its contents.</td>
<td><a href="pt/DOM/Node">Node</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.dispatchEvent">dispatchEvent</a>( <a href="pt/DOM/event">event</a> )</code><br>
Dispatch an event to this node in the DOM.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.focus">focus</a>()</code><br>
Gives keyboard focus to the current element.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a>, <a href="pt/XUL">XUL</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getAttribute">getAttribute</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve the value of the named attribute from the current node.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getAttributeNS">getAttributeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve the value of the attribute with the specified name and namespace, from the current node.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getAttributeNode">getAttributeNode</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve the node representation of the named attribute from the current node.</td>
<td><a href="pt/DOM/Attr">Attr</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getAttributeNodeNS">getAttributeNodeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve the node representation of the attribute with the specified name and namespace, from the current node.</td>
<td><a href="pt/DOM/Attr">Attr</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<th>Name &amp; Description</th>
<th>Return</th>
<th>Availability</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getElementsByTagName">getElementsByTagName</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve a set of all descendant elements, of a particular tag name, from the current element.</td>
<td><a href="pt/DOM/NodeSet">NodeSet</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.getElementsByTagNameNS">getElementsByTagNameNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Retrieve a set of all descendant elements, of a particular tag name and namespace, from the current element.</td>
<td><a href="pt/DOM/NodeSet">NodeSet</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.hasAttribute">hasAttribute</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Check if the element has the specified attribute, or not.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.hasAttributeNS">hasAttributeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Check if the element has the specified attribute, in the specified namespace, or not.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.hasAttributes">hasAttributes</a>()</code><br>
Check if the element has any attributes, or not.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.hasChildNodes">hasChildNodes</a>()</code><br>
Check if the element has any child nodes, or not.</td>
<td><a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">Boolean</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.insertBefore">insertBefore</a>( <a href="pt/DOM/Node">insertedNode</a>, <a href="pt/DOM/Node">adjacentNode</a> )</code><br>
Inserts the first node before the second, child, Node in the DOM.</td>
<td><a href="pt/DOM/Node">Node</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.normalize">normalize</a>()</code><br>
Clean up all the text nodes under this element (merge adjacent, remove empty).</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.removeAttribute">removeAttribute</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Remove the named attribute from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.removeAttributeNS">removeAttributeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Remove the attribute with the specified name and namespace, from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<th>Name &amp; Description</th>
<th>Return</th>
<th>Availability</th>
</tr>
<tr>
<td><code><a href="pt/DOM/element.removeAttributeNode">removeAttributeNode</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a> )</code><br>
Remove the node representation of the named attribute from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.removeChild">removeChild</a>( <a href="pt/DOM/Node">removedNode</a> )</code><br>
Removes a child node from the current element.</td>
<td><a href="pt/DOM/Node">Node</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.removeEventListener">removeEventListener</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">type</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Function">handler</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">useCapture</a> )</code><br>
Removes an event listener from the element.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM/event">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.replaceChild">replaceChild</a>( <a href="pt/DOM/Node">insertedNode</a>, <a href="pt/DOM/Node">replacedNode</a> )</code><br>
Replaces one child node in the current element with another.</td>
<td><a href="pt/DOM/Node">Node</a></td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.scrollIntoView">scrollIntoView</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">alignWithTop</a> )</code><br>
Scrolls the page until the element gets into the view.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/HTML">HTML</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.setAttribute">setAttribute</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Object">value</a> )</code><br>
Set the value of the named attribute from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.setAttributeNS">setAttributeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/Object">value</a> )</code><br>
Set the value of the attribute with the specified name and namespace, from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.setAttributeNode">setAttributeNode</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a>, <a href="pt/DOM/Attr">attrNode</a> )</code><br>
Set the node representation of the named attribute from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
<tr>
<td><code><a href="pt/DOM/element.setAttributeNodeNS">setAttributeNodeNS</a>( <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">namespace</a>, <a href="pt/Core_JavaScript_1.5_Reference/Global_Objects/String">name</a>, <a href="pt/DOM/Attr">attrNode</a> )</code><br>
Set the node representation of the attribute with the specified name and namespace, from the current node.</td>
<td>-</td>
<td nowrap="nowrap"><small><a href="pt/DOM">All</a></small></td>
</tr>
</tbody></table>
<h3 name="Event_Handlers"> Event Handlers </h3>
<p>These are properties that correspond to the HTML 'on' event attributes.
</p><p>Unlike the corresponding attributes, the values of these properties are functions (or any other object implementing the <a class="external" href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-EventListener">EventListener</a> interface) rather than a string. In fact, assigning an event attribute in HTML creates a wrapper function around the specified code. For example, given the following HTML:
</p>
<pre>&lt;div onclick="foo();"&gt;click me!&lt;/div&gt;
</pre>
<p>If <code>element</code> is a reference to this <code>div</code>, the value of <code>element.onclick</code> is effectively:
</p>
<pre>function onclick(event) {
   foo();
}
</pre>
<p>Note how the <a href="pt/DOM/event">event</a> object is passed as parameter <code>event</code> to this wrapper function.
</p>
<dl><dt> <a href="pt/DOM/element.onblur">onblur</a>
</dt><dd> Returns the event handling code for the blur event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onchange">onchange</a>
</dt><dd> Returns the event handling code for the change event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onclick">onclick</a>
</dt><dd> Returns the event handling code for the click event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.ondblclick">ondblclick</a>
</dt><dd> Returns the event handling code for the dblclick event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onfocus">onfocus</a>
</dt><dd> Returns the event handling code for the focus event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onkeydown">onkeydown</a>
</dt><dd> Returns the event handling code for the keydown event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onkeypress">onkeypress</a>
</dt><dd> Returns the event handling code for the keypress event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onkeyup">onkeyup</a>
</dt><dd> Returns the event handling code for the keyup event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onmousedown">onmousedown</a>
</dt><dd> Returns the event handling code for the mousedown event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onmousemove">onmousemove</a>
</dt><dd> Returns the event handling code for the mousemove event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onmouseout">onmouseout</a>
</dt><dd> Returns the event handling code for the mouseout event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onmouseover">onmouseover</a>
</dt><dd> Returns the event handling code for the mouseover event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onmouseup">onmouseup</a>
</dt><dd> Returns the event handling code for the mouseup event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onresize">onresize</a>
</dt><dd> Returns the event handling code for the resize event.
</dd></dl>
<dl><dt> <a href="pt/DOM/element.onscroll">onscroll</a>
</dt><dd> Returns the event handling code for the scroll event.
</dd></dl>
<div class="noinclude">
</div>
{{ wiki.languages( { "es": "es/DOM/element", "fr": "fr/DOM/element", "ja": "ja/DOM/element", "pl": "pl/DOM/element", "en": "en/DOM/element", "zh-cn": "cn/DOM/element" } ) }}
Reverter para esta revisão