public interface Element extends Node, NodeSelector, ElementTraversal
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
Modifier and Type | Field and Description |
---|---|
static int |
ALLOW_KEYBOARD_INPUT |
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
Modifier and Type | Method and Description |
---|---|
void |
blur()
Removes keyboard focus from the current element.
|
void |
click()
Simulates a click on the current element.
|
void |
focus()
Gives keyboard focus to the current element.
|
String |
getAccessKey() |
String |
getAttribute(String name)
Retrieve the value of the named attribute from the current node.
|
Attr |
getAttributeNode(String name)
Retrieve the node representation of the named attribute from the current node.
|
Attr |
getAttributeNodeNS(String namespaceURI,
String localName)
Retrieve the node representation of the attribute with the specified name and namespace, from the current node.
|
String |
getAttributeNS(String namespaceURI,
String localName)
Retrieve the value of the attribute with the specified name and namespace, from the current node.
|
ClientRect |
getBoundingClientRect() |
int |
getChildElementCount()
The number of child nodes that are elements.
|
HTMLCollection |
getChildren()
A live
nsIDOMNodeList
of the current child elements. |
DOMTokenList |
getClassList()
Token list of class attribute
|
String |
getClassName()
Gets/sets the class of the element.
|
int |
getClientHeight()
The inner height of an element.
|
int |
getClientLeft()
The width of the left border of an element.
|
ClientRectList |
getClientRects() |
int |
getClientTop()
The width of the top border of an element.
|
int |
getClientWidth()
The inner width of an element.
|
String |
getContentEditable()
Gets/sets whether or not the element is editable.
|
Mappable |
getDataset()
Allows access to read and write custom data attributes on the element.
|
String |
getDir()
Gets/sets the directionality of the element.
|
NodeList |
getElementsByClassName(String name) |
NodeList |
getElementsByTagName(String name)
Retrieve a set of all descendant elements, of a particular tag name, from the current element.
|
NodeList |
getElementsByTagNameNS(String namespaceURI,
String localName)
Retrieve a set of all descendant elements, of a particular tag name and namespace, from the current element.
|
Element |
getFirstElementChild()
The first direct child element of an element, or
null if the element has no child elements. |
String |
getId()
Gets/sets the id of the element.
|
String |
getInnerHTML()
Gets/sets the markup of the element's content.
|
String |
getInnerText() |
String |
getLang()
Gets/sets the language of an element's attributes, text, and element contents.
|
Element |
getLastElementChild()
The last direct child element of an element, or
null if the element has no child elements. |
Element |
getNextElementSibling()
The element immediately following the given one in the tree, or
null if there's no sibling node. |
int |
getOffsetHeight()
The height of an element, relative to the layout.
|
int |
getOffsetLeft()
The distance from this element's left border to its
offsetParent 's left border. |
Element |
getOffsetParent()
The element from which all offset calculations are currently computed.
|
int |
getOffsetTop()
The distance from this element's top border to its
offsetParent 's top border. |
int |
getOffsetWidth()
The width of an element, relative to the layout.
|
EventListener |
getOnabort() |
EventListener |
getOnbeforecopy() |
EventListener |
getOnbeforecut() |
EventListener |
getOnbeforepaste() |
EventListener |
getOnblur()
Returns the event handling code for the blur event.
|
EventListener |
getOnchange()
Returns the event handling code for the change event.
|
EventListener |
getOnclick()
Returns the event handling code for the click event.
|
EventListener |
getOncontextmenu()
Returns the event handling code for the contextmenu event.
|
EventListener |
getOncopy()
Returns the event handling code for the copy event.
|
EventListener |
getOncut()
Returns the event handling code for the cut event.
|
EventListener |
getOndblclick()
Returns the event handling code for the dblclick event.
|
EventListener |
getOndrag() |
EventListener |
getOndragend() |
EventListener |
getOndragenter() |
EventListener |
getOndragleave() |
EventListener |
getOndragover() |
EventListener |
getOndragstart() |
EventListener |
getOndrop() |
EventListener |
getOnerror() |
EventListener |
getOnfocus()
Returns the event handling code for the focus event.
|
EventListener |
getOninput() |
EventListener |
getOninvalid() |
EventListener |
getOnkeydown()
Returns the event handling code for the keydown event.
|
EventListener |
getOnkeypress()
Returns the event handling code for the keypress event.
|
EventListener |
getOnkeyup()
Returns the event handling code for the keyup event.
|
EventListener |
getOnload() |
EventListener |
getOnmousedown()
Returns the event handling code for the mousedown event.
|
EventListener |
getOnmousemove()
Returns the event handling code for the mousemove event.
|
EventListener |
getOnmouseout()
Returns the event handling code for the mouseout event.
|
EventListener |
getOnmouseover()
Returns the event handling code for the mouseover event.
|
EventListener |
getOnmouseup()
Returns the event handling code for the mouseup event.
|
EventListener |
getOnmousewheel() |
EventListener |
getOnpaste()
Returns the event handling code for the paste event.
|
EventListener |
getOnreset() |
EventListener |
getOnscroll()
Returns the event handling code for the scroll event.
|
EventListener |
getOnsearch() |
EventListener |
getOnselect() |
EventListener |
getOnselectstart() |
EventListener |
getOnsubmit() |
EventListener |
getOntouchcancel() |
EventListener |
getOntouchend() |
EventListener |
getOntouchmove() |
EventListener |
getOntouchstart() |
EventListener |
getOnwebkitfullscreenchange() |
EventListener |
getOnwebkitfullscreenerror() |
String |
getOuterHTML()
Gets the markup of the element including its content.
|
String |
getOuterText() |
Element |
getPreviousElementSibling()
The element immediately preceding the given one in the tree, or
null if there is no sibling element. |
int |
getScrollHeight()
The scroll view height of an element.
|
int |
getScrollLeft()
Gets/sets the left scroll offset of an element.
|
int |
getScrollTop()
Gets/sets the top scroll offset of an element.
|
int |
getScrollWidth()
The scroll view width of an element.
|
CSSStyleDeclaration |
getStyle()
An object representing the declarations of an element's style attributes.
|
int |
getTabIndex()
Gets/sets the position of the element in the tabbing order.
|
String |
getTagName()
The name of the tag for the given element.
|
String |
getTitle()
A string that appears in a popup box when mouse is over the element.
|
String |
getWebkitdropzone() |
String |
getWebkitRegionOverflow() |
boolean |
hasAttribute(String name)
Check if the element has the specified attribute, or not.
|
boolean |
hasAttributeNS(String namespaceURI,
String localName)
Check if the element has the specified attribute, in the specified namespace, or not.
|
Element |
insertAdjacentElement(String where,
Element element) |
void |
insertAdjacentHTML(String where,
String html)
Parses the text as HTML or XML and inserts the resulting nodes into the tree in the position given.
|
void |
insertAdjacentText(String where,
String text) |
boolean |
isContentEditable()
Indicates whether or not the content of the element can be edited.
|
boolean |
isDraggable() |
boolean |
isHidden() |
boolean |
isSpellcheck()
Controls spell-checking (present on all HTML elements)
|
boolean |
isTranslate() |
Element |
querySelector(String selectors) |
NodeList |
querySelectorAll(String selectors) |
void |
removeAttribute(String name)
Remove the named attribute from the current node.
|
Attr |
removeAttributeNode(Attr oldAttr)
Remove the node representation of the named attribute from the current node.
|
void |
removeAttributeNS(String namespaceURI,
String localName)
Remove the attribute with the specified name and namespace, from the current node.
|
void |
scrollByLines(int lines) |
void |
scrollByPages(int pages) |
void |
scrollIntoView()
Scrolls the page until the element gets into the view.
|
void |
scrollIntoView(boolean alignWithTop)
Scrolls the page until the element gets into the view.
|
void |
scrollIntoViewIfNeeded() |
void |
scrollIntoViewIfNeeded(boolean centerIfNeeded) |
void |
setAccessKey(String arg) |
void |
setAttribute(String name,
String value)
Set the value of the named attribute from the current node.
|
Attr |
setAttributeNode(Attr newAttr)
Set the node representation of the named attribute from the current node.
|
Attr |
setAttributeNodeNS(Attr newAttr)
Set the node representation of the attribute with the specified name and namespace, from the current node.
|
void |
setAttributeNS(String namespaceURI,
String qualifiedName,
String value)
Set the value of the attribute with the specified name and namespace, from the current node.
|
void |
setClassName(String arg) |
void |
setContentEditable(String arg) |
void |
setDir(String arg) |
void |
setDraggable(boolean arg) |
void |
setHidden(boolean arg) |
void |
setId(String arg) |
void |
setInnerHTML(String arg) |
void |
setInnerText(String arg) |
void |
setLang(String arg) |
void |
setOnabort(EventListener arg) |
void |
setOnbeforecopy(EventListener arg) |
void |
setOnbeforecut(EventListener arg) |
void |
setOnbeforepaste(EventListener arg) |
void |
setOnblur(EventListener arg) |
void |
setOnchange(EventListener arg) |
void |
setOnclick(EventListener arg) |
void |
setOncontextmenu(EventListener arg) |
void |
setOncopy(EventListener arg) |
void |
setOncut(EventListener arg) |
void |
setOndblclick(EventListener arg) |
void |
setOndrag(EventListener arg) |
void |
setOndragend(EventListener arg) |
void |
setOndragenter(EventListener arg) |
void |
setOndragleave(EventListener arg) |
void |
setOndragover(EventListener arg) |
void |
setOndragstart(EventListener arg) |
void |
setOndrop(EventListener arg) |
void |
setOnerror(EventListener arg) |
void |
setOnfocus(EventListener arg) |
void |
setOninput(EventListener arg) |
void |
setOninvalid(EventListener arg) |
void |
setOnkeydown(EventListener arg) |
void |
setOnkeypress(EventListener arg) |
void |
setOnkeyup(EventListener arg) |
void |
setOnload(EventListener arg) |
void |
setOnmousedown(EventListener arg) |
void |
setOnmousemove(EventListener arg) |
void |
setOnmouseout(EventListener arg) |
void |
setOnmouseover(EventListener arg) |
void |
setOnmouseup(EventListener arg) |
void |
setOnmousewheel(EventListener arg) |
void |
setOnpaste(EventListener arg) |
void |
setOnreset(EventListener arg) |
void |
setOnscroll(EventListener arg) |
void |
setOnsearch(EventListener arg) |
void |
setOnselect(EventListener arg) |
void |
setOnselectstart(EventListener arg) |
void |
setOnsubmit(EventListener arg) |
void |
setOntouchcancel(EventListener arg) |
void |
setOntouchend(EventListener arg) |
void |
setOntouchmove(EventListener arg) |
void |
setOntouchstart(EventListener arg) |
void |
setOnwebkitfullscreenchange(EventListener arg) |
void |
setOnwebkitfullscreenerror(EventListener arg) |
void |
setOuterHTML(String arg) |
void |
setOuterText(String arg) |
void |
setScrollLeft(int arg) |
void |
setScrollTop(int arg) |
void |
setSpellcheck(boolean arg) |
void |
setTabIndex(int arg) |
void |
setTitle(String arg) |
void |
setTranslate(boolean arg) |
void |
setWebkitdropzone(String arg) |
boolean |
webkitMatchesSelector(String selectors)
Returns whether or not the element would be selected by the specified selector string.
|
void |
webkitRequestFullscreen() |
void |
webkitRequestFullScreen(int flags)
Asynchronously asks the browser to make the element full-screen.
|
addEventListener, addEventListener, appendChild, cloneNode, compareDocumentPosition, contains, dispatchEvent, getAttributes, getBaseURI, getChildNodes, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPrefix, getPreviousSibling, getTextContent, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, removeEventListener, removeEventListener, replaceChild, setNodeValue, setPrefix, setTextContent
static final int ALLOW_KEYBOARD_INPUT
String getAccessKey()
void setAccessKey(String arg)
int getChildElementCount()
getChildElementCount
in interface ElementTraversal
HTMLCollection getChildren()
nsIDOMNodeList
of the current child elements.DOMTokenList getClassList()
String getClassName()
void setClassName(String arg)
int getClientHeight()
int getClientLeft()
int getClientTop()
int getClientWidth()
String getContentEditable()
void setContentEditable(String arg)
Mappable getDataset()
String getDir()
void setDir(String arg)
boolean isDraggable()
void setDraggable(boolean arg)
Element getFirstElementChild()
null
if the element has no child elements.getFirstElementChild
in interface ElementTraversal
boolean isHidden()
void setHidden(boolean arg)
String getId()
void setId(String arg)
String getInnerHTML()
void setInnerHTML(String arg)
String getInnerText()
void setInnerText(String arg)
boolean isContentEditable()
String getLang()
void setLang(String arg)
Element getLastElementChild()
null
if the element has no child elements.getLastElementChild
in interface ElementTraversal
Element getNextElementSibling()
null
if there's no sibling node.getNextElementSibling
in interface ElementTraversal
int getOffsetHeight()
int getOffsetLeft()
offsetParent
's left border.Element getOffsetParent()
int getOffsetTop()
offsetParent
's top border.int getOffsetWidth()
EventListener getOnabort()
void setOnabort(EventListener arg)
EventListener getOnbeforecopy()
void setOnbeforecopy(EventListener arg)
EventListener getOnbeforecut()
void setOnbeforecut(EventListener arg)
EventListener getOnbeforepaste()
void setOnbeforepaste(EventListener arg)
EventListener getOnblur()
void setOnblur(EventListener arg)
EventListener getOnchange()
void setOnchange(EventListener arg)
EventListener getOnclick()
void setOnclick(EventListener arg)
EventListener getOncontextmenu()
void setOncontextmenu(EventListener arg)
EventListener getOncopy()
void setOncopy(EventListener arg)
EventListener getOncut()
void setOncut(EventListener arg)
EventListener getOndblclick()
void setOndblclick(EventListener arg)
EventListener getOndrag()
void setOndrag(EventListener arg)
EventListener getOndragend()
void setOndragend(EventListener arg)
EventListener getOndragenter()
void setOndragenter(EventListener arg)
EventListener getOndragleave()
void setOndragleave(EventListener arg)
EventListener getOndragover()
void setOndragover(EventListener arg)
EventListener getOndragstart()
void setOndragstart(EventListener arg)
EventListener getOndrop()
void setOndrop(EventListener arg)
EventListener getOnerror()
void setOnerror(EventListener arg)
EventListener getOnfocus()
void setOnfocus(EventListener arg)
EventListener getOninput()
void setOninput(EventListener arg)
EventListener getOninvalid()
void setOninvalid(EventListener arg)
EventListener getOnkeydown()
void setOnkeydown(EventListener arg)
EventListener getOnkeypress()
void setOnkeypress(EventListener arg)
EventListener getOnkeyup()
void setOnkeyup(EventListener arg)
EventListener getOnload()
void setOnload(EventListener arg)
EventListener getOnmousedown()
void setOnmousedown(EventListener arg)
EventListener getOnmousemove()
void setOnmousemove(EventListener arg)
EventListener getOnmouseout()
void setOnmouseout(EventListener arg)
EventListener getOnmouseover()
void setOnmouseover(EventListener arg)
EventListener getOnmouseup()
void setOnmouseup(EventListener arg)
EventListener getOnmousewheel()
void setOnmousewheel(EventListener arg)
EventListener getOnpaste()
void setOnpaste(EventListener arg)
EventListener getOnreset()
void setOnreset(EventListener arg)
EventListener getOnscroll()
void setOnscroll(EventListener arg)
EventListener getOnsearch()
void setOnsearch(EventListener arg)
EventListener getOnselect()
void setOnselect(EventListener arg)
EventListener getOnselectstart()
void setOnselectstart(EventListener arg)
EventListener getOnsubmit()
void setOnsubmit(EventListener arg)
EventListener getOntouchcancel()
void setOntouchcancel(EventListener arg)
EventListener getOntouchend()
void setOntouchend(EventListener arg)
EventListener getOntouchmove()
void setOntouchmove(EventListener arg)
EventListener getOntouchstart()
void setOntouchstart(EventListener arg)
EventListener getOnwebkitfullscreenchange()
void setOnwebkitfullscreenchange(EventListener arg)
EventListener getOnwebkitfullscreenerror()
void setOnwebkitfullscreenerror(EventListener arg)
String getOuterHTML()
void setOuterHTML(String arg)
String getOuterText()
void setOuterText(String arg)
Element getPreviousElementSibling()
null
if there is no sibling element.getPreviousElementSibling
in interface ElementTraversal
int getScrollHeight()
int getScrollLeft()
void setScrollLeft(int arg)
int getScrollTop()
void setScrollTop(int arg)
int getScrollWidth()
boolean isSpellcheck()
void setSpellcheck(boolean arg)
CSSStyleDeclaration getStyle()
int getTabIndex()
void setTabIndex(int arg)
String getTagName()
String getTitle()
void setTitle(String arg)
boolean isTranslate()
void setTranslate(boolean arg)
String getWebkitRegionOverflow()
String getWebkitdropzone()
void setWebkitdropzone(String arg)
void blur()
void focus()
String getAttribute(String name)
String getAttributeNS(String namespaceURI, String localName)
Attr getAttributeNode(String name)
Attr getAttributeNodeNS(String namespaceURI, String localName)
ClientRect getBoundingClientRect()
ClientRectList getClientRects()
NodeList getElementsByTagName(String name)
NodeList getElementsByTagNameNS(String namespaceURI, String localName)
boolean hasAttribute(String name)
boolean hasAttributeNS(String namespaceURI, String localName)
Element querySelector(String selectors)
querySelector
in interface NodeSelector
NodeList querySelectorAll(String selectors)
querySelectorAll
in interface NodeSelector
void removeAttribute(String name)
void removeAttributeNS(String namespaceURI, String localName)
Attr removeAttributeNode(Attr oldAttr)
void scrollByLines(int lines)
void scrollByPages(int pages)
void scrollIntoView()
void scrollIntoView(boolean alignWithTop)
void scrollIntoViewIfNeeded()
void scrollIntoViewIfNeeded(boolean centerIfNeeded)
void setAttribute(String name, String value)
void setAttributeNS(String namespaceURI, String qualifiedName, String value)
Attr setAttributeNode(Attr newAttr)
Attr setAttributeNodeNS(Attr newAttr)
boolean webkitMatchesSelector(String selectors)
void webkitRequestFullScreen(int flags)
void webkitRequestFullscreen()
void click()
void insertAdjacentHTML(String where, String html)
Copyright © 2016. All rights reserved.