public class

Element

extends Node
java.lang.Object
   ↳ com.google.gwt.core.client.JavaScriptObject
     ↳ com.google.gwt.dom.client.Node
       ↳ com.google.gwt.dom.client.Element
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

All HTML element interfaces derive from this class.

Summary

[Expand]
Inherited Constants
From class com.google.gwt.dom.client.Node
Protected Constructors
Element()
Public Methods
final void addClassName(String className)
Adds a name to this element's class property.
static Element as(JavaScriptObject o)
Assert that the given Node is an Element and automatically typecast it.
static Element as(Node node)
Assert that the given Node is an Element and automatically typecast it.
final void blur()
Removes keyboard focus from this element.
final void dispatchEvent(NativeEvent evt)
Dispatched the given event with this element as its target.
final void focus()
Gives keyboard focus to this element.
final int getAbsoluteBottom()
Gets an element's absolute bottom coordinate in the document's coordinate system.
final int getAbsoluteLeft()
Gets an element's absolute left coordinate in the document's coordinate system.
final int getAbsoluteRight()
Gets an element's absolute right coordinate in the document's coordinate system.
final int getAbsoluteTop()
Gets an element's absolute top coordinate in the document's coordinate system.
final String getAttribute(String name)
Retrieves an attribute value by name.
final String getClassName()
The class attribute of the element.
final int getClientHeight()
Returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.
final int getClientWidth()
Returns the inner width of an element in pixels, including padding but not the vertical scrollbar width, border, or margin.
final String getDir()
Specifies the base direction of directionally neutral text and the directionality of tables.
final NodeList<Element> getElementsByTagName(String name)
Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.
final Element getFirstChildElement()
The first child of element this element.
final String getId()
The element's identifier.
final String getInnerHTML()
All of the markup and content within a given element.
final String getInnerText()
The text between the start and end tags of the object.
final String getLang()
Language code defined in RFC 1766.
final Element getNextSiblingElement()
The element immediately following this element.
final int getOffsetHeight()
The height of an element relative to the layout.
final int getOffsetLeft()
The number of pixels that the upper left corner of the current element is offset to the left within the offsetParent node.
final Element getOffsetParent()
Returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element.
final int getOffsetTop()
The number of pixels that the upper top corner of the current element is offset to the top within the offsetParent node.
final int getOffsetWidth()
The width of an element relative to the layout.
final boolean getPropertyBoolean(String name)
Gets a boolean property from this element.
final double getPropertyDouble(String name)
Gets a double property from this element.
final int getPropertyInt(String name)
Gets an integer property from this element.
final JavaScriptObject getPropertyJSO(String name)
Gets a JSO property from this element.
final Object getPropertyObject(String name)
Gets an object property from this element.
final String getPropertyString(String name)
Gets a property from this element.
final int getScrollHeight()
The height of the scroll view of an element.
final int getScrollLeft()
The number of pixels that an element's content is scrolled from the left.
final int getScrollTop()
The number of pixels that an element's content is scrolled from the top.
final int getScrollWidth()
The width of the scroll view of an element.
final String getString()
Gets a string representation of this element (as outer HTML).
final Style getStyle()
Gets this element's Style object.
final int getTabIndex()
The index that represents the element's position in the tabbing order.
final String getTagName()
Gets the element's full tag name, including the namespace-prefix if present.
final String getTitle()
The element's advisory title.
final boolean hasAttribute(String name)
Determines whether an element has an attribute with a given name.
final boolean hasTagName(String tagName)
Determines whether this element has the given tag name.
static boolean is(Node node)
Determine whether the given Node can be cast to an Element.
static boolean is(JavaScriptObject o)
Determines whether the given JavaScriptObject can be cast to an Element.
final void removeAttribute(String name)
Removes an attribute by name.
final void removeClassName(String className)
Removes a name from this element's class property.
final void replaceClassName(String oldClassName, String newClassName)
Replace one class name with another.
final void scrollIntoView()
Scrolls this element into view.
final void setAttribute(String name, String value)
Adds a new attribute.
final void setClassName(String className)
The class attribute of the element.
final void setDir(String dir)
Specifies the base direction of directionally neutral text and the directionality of tables.
final void setId(String id)
The element's identifier.
final void setInnerHTML(String html)
All of the markup and content within a given element.
final void setInnerText(String text)
The text between the start and end tags of the object.
final void setLang(String lang)
Language code defined in RFC 1766.
final void setPropertyBoolean(String name, boolean value)
Sets a boolean property on this element.
final void setPropertyDouble(String name, double value)
Sets a double property on this element.
final void setPropertyInt(String name, int value)
Sets an integer property on this element.
final void setPropertyJSO(String name, JavaScriptObject value)
Sets a JSO property on this element.
final void setPropertyObject(String name, Object value)
Sets an object property on this element.
final void setPropertyString(String name, String value)
Sets a property on this element.
final void setScrollLeft(int scrollLeft)
The number of pixels that an element's content is scrolled to the left.
final void setScrollTop(int scrollTop)
The number of pixels that an element's content is scrolled to the top.
final void setTabIndex(int tabIndex)
The index that represents the element's position in the tabbing order.
final void setTitle(String title)
The element's advisory title.
[Expand]
Inherited Methods
From class com.google.gwt.dom.client.Node
From class com.google.gwt.core.client.JavaScriptObject
From class java.lang.Object

Protected Constructors

protected Element ()

Public Methods

public final void addClassName (String className)

Adds a name to this element's class property. If the name is already present, this method has no effect.

Parameters
className the class name to be added

public static Element as (JavaScriptObject o)

Assert that the given Node is an Element and automatically typecast it.

public static Element as (Node node)

Assert that the given Node is an Element and automatically typecast it.

public final void blur ()

Removes keyboard focus from this element.

public final void dispatchEvent (NativeEvent evt)

Dispatched the given event with this element as its target. The event will go through all phases of the browser's normal event dispatch mechanism. Note: Because the browser's normal dispatch mechanism is used, exceptions thrown from within handlers triggered by this method cannot be caught by wrapping this method in a try/catch block. Such exceptions will be caught by the uncaught exception handler as usual.

Parameters
evt the event to be dispatched

public final void focus ()

Gives keyboard focus to this element.

public final int getAbsoluteBottom ()

Gets an element's absolute bottom coordinate in the document's coordinate system.

public final int getAbsoluteLeft ()

Gets an element's absolute left coordinate in the document's coordinate system.

public final int getAbsoluteRight ()

Gets an element's absolute right coordinate in the document's coordinate system.

public final int getAbsoluteTop ()

Gets an element's absolute top coordinate in the document's coordinate system.

public final String getAttribute (String name)

Retrieves an attribute value by name. Attribute support can be inconsistent across various browsers. Consider using the accessors in Element and its specific subclasses to retrieve attributes and properties.

Parameters
name The name of the attribute to retrieve
Returns
  • The Attr value as a string, or the empty string if that attribute does not have a specified or default value

public final String getClassName ()

The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages.

public final int getClientHeight ()

Returns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.

Returns
  • the element's client height

public final int getClientWidth ()

Returns the inner width of an element in pixels, including padding but not the vertical scrollbar width, border, or margin.

Returns
  • the element's client width

public final String getDir ()

Specifies the base direction of directionally neutral text and the directionality of tables.

public final NodeList<Element> getElementsByTagName (String name)

Returns a NodeList of all descendant Elements with a given tag name, in the order in which they are encountered in a preorder traversal of this Element tree.

Parameters
name The name of the tag to match on. The special value "*" matches all tags
Returns
  • A list of matching Element nodes

public final Element getFirstChildElement ()

The first child of element this element. If there is no such element, this returns null.

public final String getId ()

The element's identifier.

public final String getInnerHTML ()

All of the markup and content within a given element.

public final String getInnerText ()

The text between the start and end tags of the object.

public final String getLang ()

Language code defined in RFC 1766.

public final Element getNextSiblingElement ()

The element immediately following this element. If there is no such element, this returns null.

public final int getOffsetHeight ()

The height of an element relative to the layout.

public final int getOffsetLeft ()

The number of pixels that the upper left corner of the current element is offset to the left within the offsetParent node.

public final Element getOffsetParent ()

Returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element.

public final int getOffsetTop ()

The number of pixels that the upper top corner of the current element is offset to the top within the offsetParent node.

public final int getOffsetWidth ()

The width of an element relative to the layout.

public final boolean getPropertyBoolean (String name)

Gets a boolean property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final double getPropertyDouble (String name)

Gets a double property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final int getPropertyInt (String name)

Gets an integer property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final JavaScriptObject getPropertyJSO (String name)

Gets a JSO property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final Object getPropertyObject (String name)

Gets an object property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final String getPropertyString (String name)

Gets a property from this element.

Parameters
name the name of the property to be retrieved
Returns
  • the property value

public final int getScrollHeight ()

The height of the scroll view of an element.

public final int getScrollLeft ()

The number of pixels that an element's content is scrolled from the left.

If the element is in RTL mode, this method will return a negative value of the number of pixels scrolled from the right.

public final int getScrollTop ()

The number of pixels that an element's content is scrolled from the top.

public final int getScrollWidth ()

The width of the scroll view of an element.

public final String getString ()

Gets a string representation of this element (as outer HTML). We do not override toString() because it is final in JavaScriptObject.

Returns
  • the string representation of this element

public final Style getStyle ()

Gets this element's Style object.

public final int getTabIndex ()

The index that represents the element's position in the tabbing order.

public final String getTagName ()

Gets the element's full tag name, including the namespace-prefix if present.

Returns
  • the element's tag name

public final String getTitle ()

The element's advisory title.

public final boolean hasAttribute (String name)

Determines whether an element has an attribute with a given name.

Note that IE, prior to version 8, will return false-positives for names that collide with element properties (e.g., style, width, and so forth).

Parameters
name the name of the attribute
Returns
  • true if this element has the specified attribute

public final boolean hasTagName (String tagName)

Determines whether this element has the given tag name.

Parameters
tagName the tag name, including namespace-prefix (if present)
Returns
  • true if the element has the given tag name

public static boolean is (Node node)

Determine whether the given Node can be cast to an Element. A null node will cause this method to return false.

public static boolean is (JavaScriptObject o)

Determines whether the given JavaScriptObject can be cast to an Element. A null object will cause this method to return false.

public final void removeAttribute (String name)

Removes an attribute by name.

public final void removeClassName (String className)

Removes a name from this element's class property. If the name is not present, this method has no effect.

Parameters
className the class name to be added

public final void replaceClassName (String oldClassName, String newClassName)

Replace one class name with another.

Parameters
oldClassName the class name to be replaced
newClassName the class name to replace it

public final void scrollIntoView ()

Scrolls this element into view.

This method crawls up the DOM hierarchy, adjusting the scrollLeft and scrollTop properties of each scrollable element to ensure that the specified element is completely in view. It adjusts each scroll position by the minimum amount necessary.

public final void setAttribute (String name, String value)

Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter.

Parameters
name The name of the attribute to create or alter
value Value to set in string form

public final void setClassName (String className)

The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages.

public final void setDir (String dir)

Specifies the base direction of directionally neutral text and the directionality of tables.

public final void setId (String id)

The element's identifier.

public final void setInnerHTML (String html)

All of the markup and content within a given element.

public final void setInnerText (String text)

The text between the start and end tags of the object.

public final void setLang (String lang)

Language code defined in RFC 1766.

public final void setPropertyBoolean (String name, boolean value)

Sets a boolean property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setPropertyDouble (String name, double value)

Sets a double property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setPropertyInt (String name, int value)

Sets an integer property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setPropertyJSO (String name, JavaScriptObject value)

Sets a JSO property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setPropertyObject (String name, Object value)

Sets an object property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setPropertyString (String name, String value)

Sets a property on this element.

Parameters
name the name of the property to be set
value the new property value

public final void setScrollLeft (int scrollLeft)

The number of pixels that an element's content is scrolled to the left.

public final void setScrollTop (int scrollTop)

The number of pixels that an element's content is scrolled to the top.

public final void setTabIndex (int tabIndex)

The index that represents the element's position in the tabbing order.

public final void setTitle (String title)

The element's advisory title.