class js.html.Element extends Node

Available on js

This chapter provides a brief reference for the general methods, properties, and events available to most HTML and XML elements in the Gecko DOM.

Various W3C specifications apply to elements:

The articles listed here span the above and include links to the appropriate W3C DOM specification.

While these interfaces are generally shared by most HTML and XML elements, there are more specialized interfaces for particular objects listed in the DOM HTML Specification. Note, however, that these HTML interfaces are "only for [HTML 4.01] and [XHTML 1.0] documents and are not guaranteed to work with any future version of XHTML." The HTML 5 draft does state it aims for backwards compatibility with these HTML interfaces but says of them that "some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed." One can avoid the potential conflict by moving entirely to DOM XML attribute methods such as getAttribute().

Html , Head , Link , Title , Meta , Base , IsIndex , Style , Body , Form , Select , OptGroup , Option, Input , TextArea , Button , Label , FieldSet , Legend , UList , OList , DList , Directory , Menu , LI , Div , Paragraph , Heading , Quote , Pre , BR , BaseFont , Font , HR , Mod , Anchor , Image , Object , Param , Applet , Map , Area , Script , Table , TableCaption , TableCol , TableSection , TableRow , TableCell , FrameSet , Frame , IFrame



Documentation for this class was provided by MDN.

Class Fields

Instance Fields

var childElementCount:Int

The number of child nodes that are elements.

var children:HTMLCollection

A live nsIDOMNodeList of the current child elements.

var classList:DOMTokenList

Token list of class attribute

var className:String

Gets/sets the class of the element.

var clientHeight:Int

The inner height of an element.

var clientLeft:Int

The width of the left border of an element.

var clientTop:Int

The width of the top border of an element.

var clientWidth:Int

The inner width of an element.

var contentEditable:String

Gets/sets whether or not the element is editable. Setter throws DOMException.

var dataset:DOMStringMap

Allows access to read and write custom data attributes on the element.

var dir:String

Gets/sets the directionality of the element.

var firstElementChild:Element

The first direct child element of an element, or null if the element has no child elements.

var id:String

Gets/sets the id of the element.

var innerHTML:String

Gets/sets the markup of the element's content. Setter throws DOMException.

var innerText:String

Setter throws DOMException.

var isContentEditable:Bool

Indicates whether or not the content of the element can be edited. Read only.

var lang:String

Gets/sets the language of an element's attributes, text, and element contents.

var lastElementChild:Element

The last direct child element of an element, or null if the element has no child elements.

var nextElementSibling:Element

The element immediately following the given one in the tree, or null if there's no sibling node.

var offsetHeight:Int

The height of an element, relative to the layout.

var offsetLeft:Int

The distance from this element's left border to its offsetParent's left border.

var offsetParent:Element

The element from which all offset calculations are currently computed.

var offsetTop:Int

The distance from this element's top border to its offsetParent's top border.

var offsetWidth:Int

The width of an element, relative to the layout.

var onblur:EventListener

Returns the event handling code for the blur event.

var onchange:EventListener

Returns the event handling code for the change event.

var onclick:EventListener

Returns the event handling code for the click event.

var oncontextmenu:EventListener

Returns the event handling code for the contextmenu event.

var oncopy:EventListener

Returns the event handling code for the copy event.

var oncut:EventListener

Returns the event handling code for the cut event.

var ondblclick:EventListener

Returns the event handling code for the dblclick event.

var onfocus:EventListener

Returns the event handling code for the focus event.

var onkeydown:EventListener

Returns the event handling code for the keydown event.

var onkeypress:EventListener

Returns the event handling code for the keypress event.

var onkeyup:EventListener

Returns the event handling code for the keyup event.

var onmousedown:EventListener

Returns the event handling code for the mousedown event.

var onmousemove:EventListener

Returns the event handling code for the mousemove event.

var onmouseout:EventListener

Returns the event handling code for the mouseout event.

var onmouseover:EventListener

Returns the event handling code for the mouseover event.

var onmouseup:EventListener

Returns the event handling code for the mouseup event.

var onpaste:EventListener

Returns the event handling code for the paste event.

var onscroll:EventListener

Returns the event handling code for the scroll event.

var outerHTML:String

Gets the markup of the element including its content. When used as a setter, replaces the element with nodes parsed from the given string. Setter throws DOMException.

var outerText:String

Setter throws DOMException.

var previousElementSibling:Element

The element immediately preceding the given one in the tree, or null if there is no sibling element.

var scrollHeight:Int

The scroll view height of an element.

var scrollLeft:Int

Gets/sets the left scroll offset of an element.

var scrollTop:Int

Gets/sets the top scroll offset of an element.

var scrollWidth:Int

The scroll view width of an element.

var spellcheck:Bool

Controls spell-checking (present on all HTML elements)

var style:CSSStyleDeclaration

An object representing the declarations of an element's style attributes.

var tabIndex:Int

Gets/sets the position of the element in the tabbing order.

var tagName:String

The name of the tag for the given element.

var title:String

A string that appears in a popup box when mouse is over the element.

function blur():Void

function click():Void

function focus():Void

function getAttribute(name:String):String

function getAttributeNS(?namespaceURI:String, localName:String):String

function getAttributeNodeNS(?namespaceURI:String, localName:String):Attr

function getElementsByTagNameNS(?namespaceURI:String, localName:String):NodeList

function hasAttribute(name:String):Bool

function hasAttributeNS(?namespaceURI:String, localName:String):Bool

function insertAdjacentElement(where:String, element:Element):Element

function insertAdjacentHTML(where:String, html:String):Void

function insertAdjacentText(where:String, text:String):Void

function matchesSelector(selectors:String):Bool

function querySelector(selectors:String):Element

function querySelectorAll(selectors:String):NodeList

function remove():Void

function removeAttribute(name:String):Void

function removeAttributeNS(namespaceURI:String, localName:String):Void

function removeAttributeNode(oldAttr:Attr):Attr

function requestFullScreen(flags:Int):Void

function scrollByLines(lines:Int):Void

function scrollByPages(pages:Int):Void

function scrollIntoView(?alignWithTop:Bool):Void

function scrollIntoViewIfNeeded(?centerIfNeeded:Bool):Void

function setAttribute(name:String, value:String):Void

function setAttributeNS(?namespaceURI:String, qualifiedName:String, value:String):Void

function setAttributeNode(newAttr:Attr):Attr

function setAttributeNodeNS(newAttr:Attr):Attr