Package com.google.gwt.dom.client
Class Element
java.lang.Object
com.google.gwt.core.client.JavaScriptObject
com.google.gwt.dom.client.Node
com.google.gwt.dom.client.Element
- Direct Known Subclasses:
AbstractImagePrototype.ImagePrototypeElement,AnchorElement,AreaElement,BaseElement,BodyElement,BRElement,ButtonElement,CanvasElement,DivElement,DListElement,Element,FieldSetElement,FormElement,FrameElement,FrameSetElement,HeadElement,HeadingElement,HRElement,IFrameElement,ImageElement,InputElement,LabelElement,LegendElement,LIElement,LinkElement,MapElement,MediaElement,MetaElement,ModElement,ObjectElement,OListElement,OptGroupElement,OptionElement,ParagraphElement,ParamElement,PotentialElement,PreElement,QuoteElement,ScriptElement,SelectElement,SourceElement,SpanElement,StyleElement,TableCaptionElement,TableCellElement,TableColElement,TableElement,TableRowElement,TableSectionElement,TextAreaElement,TitleElement,UListElement
All HTML element interfaces derive from this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant returned fromgetDraggable().static final StringConstant returned fromgetDraggable().static final StringConstant returned fromgetDraggable().Fields inherited from class com.google.gwt.dom.client.Node
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanaddClassName(String className) Adds a name to this element's class property.static Elementstatic Elementfinal voidblur()Removes keyboard focus from this element.final voiddispatchEvent(NativeEvent evt) Dispatched the given event with this element as its target.final voidfocus()Gives keyboard focus to this element.final intGets an element's absolute bottom coordinate in the document's coordinate system.final intGets an element's absolute left coordinate in the document's coordinate system.final intGets an element's absolute right coordinate in the document's coordinate system.final intGets an element's absolute top coordinate in the document's coordinate system.final StringgetAttribute(String name) Retrieves an attribute value by name.final StringThe class attribute of the element.final intReturns the inner height of an element in pixels, including padding but not the horizontal scrollbar height, border, or margin.final intReturns the inner width of an element in pixels, including padding but not the vertical scrollbar width, border, or margin.final StringgetDir()Specifies the base direction of directionally neutral text and the directionality of tables.final StringReturns the draggable attribute of this 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 ElementThe first child of element this element.final StringgetId()The element's identifier.final StringAll of the markup and content within a given element.final StringThe text between the start and end tags of the object.final StringgetLang()Language code defined in RFC 1766.final ElementThe element immediately following this element.final intThe height of an element relative to the layout.final intThe number of pixels that the upper left corner of the current element is offset to the left within the offsetParent node.final ElementReturns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element.final intThe number of pixels that the upper top corner of the current element is offset to the top within the offsetParent node.final intThe width of an element relative to the layout.final ElementThe element immediately preceding this element.final booleangetPropertyBoolean(String name) Gets a boolean property from this element.final doublegetPropertyDouble(String name) Gets a double property from this element.final intgetPropertyInt(String name) Gets an integer property from this element.final JavaScriptObjectgetPropertyJSO(String name) Gets a JSO property from this element.final ObjectgetPropertyObject(String name) Gets an object property from this element.final StringgetPropertyString(String name) Gets a property from this element.final intThe height of the scroll view of an element.final intThe number of pixels that an element's content is scrolled from the left.final intThe number of pixels that an element's content is scrolled from the top.final intThe width of the scroll view of an element.final StringGets a string representation of this element (as outer HTML).final StylegetStyle()Gets this element'sStyleobject.final intThe index that represents the element's position in the tabbing order.final StringGets the element's full tag name, including the namespace-prefix if present.final StringgetTitle()The element's advisory title.final booleanhasAttribute(String name) Determines whether an element has an attribute with a given name.final booleanhasClassName(String className) Checks if this element's class property contains specified class name.final booleanhasTagName(String tagName) Determines whether this element has the given tag name.(package private) static intindexOfName(String nameList, String name) Returns the index of the first occurrence of name in a space-separated list of names, or -1 if not found.static booleanDetermines whether the givenJavaScriptObjectcan be cast to anElement.static booleanfinal voidremoveAttribute(String name) Removes an attribute by name.final booleanremoveClassName(String className) Removes a name from this element's class property.final voidreplaceClassName(String oldClassName, String newClassName) Replace one class name with another.final voidScrolls this element into view.final voidsetAttribute(String name, String value) Adds a new attribute.final voidsetClassName(String className) The class attribute of the element.final voidSpecifies the base direction of directionally neutral text and the directionality of tables.final voidsetDraggable(String draggable) final voidThe element's identifier.final voidsetInnerHTML(String html) All of the markup and content within a given element.final voidsetInnerSafeHtml(SafeHtml html) All of the markup and content within a given element.final voidsetInnerText(String text) The text between the start and end tags of the object.final voidLanguage code defined in RFC 1766.final voidsetPropertyBoolean(String name, boolean value) Sets a boolean property on this element.final voidsetPropertyDouble(String name, double value) Sets a double property on this element.final voidsetPropertyInt(String name, int value) Sets an integer property on this element.final voidsetPropertyJSO(String name, JavaScriptObject value) Sets a JSO property on this element.final voidsetPropertyObject(String name, Object value) Sets an object property on this element.final voidsetPropertyString(String name, String value) Sets a property on this element.final voidsetScrollLeft(int scrollLeft) The number of pixels that an element's content is scrolled to the left.final voidsetScrollTop(int scrollTop) The number of pixels that an element's content is scrolled to the top.final voidsetTabIndex(int tabIndex) The index that represents the element's position in the tabbing order.final voidThe element's advisory title.final voidtoggleClassName(String className) Add the class name if it doesn't exist or removes it if does.Methods inherited from class com.google.gwt.dom.client.Node
appendChild, cloneNode, getChild, getChildCount, getChildNodes, getFirstChild, getLastChild, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentElement, getParentNode, getPreviousSibling, hasChildNodes, hasParentElement, insertAfter, insertBefore, insertFirst, isOrHasChild, removeAllChildren, removeChild, removeFromParent, replaceChild, setNodeValueMethods inherited from class com.google.gwt.core.client.JavaScriptObject
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
-
Field Details
-
DRAGGABLE_AUTO
Constant returned fromgetDraggable().- See Also:
-
DRAGGABLE_FALSE
Constant returned fromgetDraggable().- See Also:
-
DRAGGABLE_TRUE
Constant returned fromgetDraggable().- See Also:
-
-
Constructor Details
-
Element
protected Element()
-
-
Method Details
-
as
-
as
-
is
Determines whether the givenJavaScriptObjectcan be cast to anElement. Anullobject will cause this method to returnfalse. -
is
-
addClassName
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- Returns:
trueif this element did not already have the specified class name- See Also:
-
blur
public final void blur()Removes keyboard focus from this element. -
dispatchEvent
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 theuncaught exception handleras usual.- Parameters:
evt- the event to be dispatched
-
focus
public final void focus()Gives keyboard focus to this element. -
getAbsoluteBottom
public final int getAbsoluteBottom()Gets an element's absolute bottom coordinate in the document's coordinate system. -
getAbsoluteLeft
public final int getAbsoluteLeft()Gets an element's absolute left coordinate in the document's coordinate system. -
getAbsoluteRight
public final int getAbsoluteRight()Gets an element's absolute right coordinate in the document's coordinate system. -
getAbsoluteTop
public final int getAbsoluteTop()Gets an element's absolute top coordinate in the document's coordinate system. -
getAttribute
Retrieves an attribute value by name. Attribute support can be inconsistent across various browsers. Consider using the accessors inElementand 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
-
getClassName
The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages.- See Also:
-
getClientHeight
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
-
getClientWidth
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
-
getDir
Specifies the base direction of directionally neutral text and the directionality of tables. -
getDraggable
Returns the draggable attribute of this element.- Returns:
- one of
DRAGGABLE_AUTO,DRAGGABLE_FALSE, orDRAGGABLE_TRUE
-
getElementsByTagName
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
-
getFirstChildElement
The first child of element this element. If there is no such element, this returns null. -
getId
The element's identifier.- See Also:
-
getInnerHTML
All of the markup and content within a given element. -
getInnerText
The text between the start and end tags of the object. -
getLang
Language code defined in RFC 1766. -
getNextSiblingElement
The element immediately following this element. If there is no such element, this returns null. -
getOffsetHeight
public final int getOffsetHeight()The height of an element relative to the layout. -
getOffsetLeft
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. -
getOffsetParent
Returns a reference to the object which is the closest (nearest in the containment hierarchy) positioned containing element. -
getOffsetTop
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. -
getOffsetWidth
public final int getOffsetWidth()The width of an element relative to the layout. -
getPreviousSiblingElement
The element immediately preceding this element. If there is no such element, this returns null. -
getPropertyBoolean
Gets a boolean property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getPropertyDouble
Gets a double property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getPropertyInt
Gets an integer property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getPropertyJSO
Gets a JSO property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getPropertyObject
Gets an object property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getPropertyString
Gets a property from this element.- Parameters:
name- the name of the property to be retrieved- Returns:
- the property value
-
getScrollHeight
public final int getScrollHeight()The height of the scroll view of an element. -
getScrollLeft
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.
-
getScrollTop
public final int getScrollTop()The number of pixels that an element's content is scrolled from the top. -
getScrollWidth
public final int getScrollWidth()The width of the scroll view of an element. -
getString
Gets a string representation of this element (as outer HTML). We do not overrideJavaScriptObject.toString()because it is final inJavaScriptObject.- Returns:
- the string representation of this element
-
getStyle
Gets this element'sStyleobject. -
getTabIndex
public final int getTabIndex()The index that represents the element's position in the tabbing order.- See Also:
-
getTagName
Gets the element's full tag name, including the namespace-prefix if present.- Returns:
- the element's tag name
-
getTitle
The element's advisory title. -
hasAttribute
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:
trueif this element has the specified attribute
-
hasClassName
Checks if this element's class property contains specified class name.- Parameters:
className- the class name to be added- Returns:
trueif this element has the specified class name
-
hasTagName
Determines whether this element has the given tag name.- Parameters:
tagName- the tag name, including namespace-prefix (if present)- Returns:
trueif the element has the given tag name
-
removeAttribute
Removes an attribute by name. -
removeClassName
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 removed- Returns:
trueif this element had the specified class name- See Also:
-
indexOfName
Returns the index of the first occurrence of name in a space-separated list of names, or -1 if not found.- Parameters:
nameList- list of space delimited namesname- a non-empty string. Should be already trimmed.
-
toggleClassName
Add the class name if it doesn't exist or removes it if does.- Parameters:
className- the class name to be toggled
-
replaceClassName
Replace one class name with another.- Parameters:
oldClassName- the class name to be replacednewClassName- the class name to replace it
-
scrollIntoView
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.
-
setAttribute
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 altervalue- Value to set in string form
-
setClassName
The class attribute of the element. This attribute has been renamed due to conflicts with the "class" keyword exposed by many languages.- See Also:
-
setDir
Specifies the base direction of directionally neutral text and the directionality of tables. -
setDraggable
- Parameters:
draggable- a String constants
-
setId
The element's identifier.- See Also:
-
setInnerHTML
All of the markup and content within a given element. -
setInnerText
The text between the start and end tags of the object. -
setLang
Language code defined in RFC 1766. -
setPropertyBoolean
Sets a boolean property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setPropertyDouble
Sets a double property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setPropertyInt
Sets an integer property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setPropertyJSO
Sets a JSO property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setPropertyObject
Sets an object property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setPropertyString
Sets a property on this element.- Parameters:
name- the name of the property to be setvalue- the new property value
-
setScrollLeft
public final void setScrollLeft(int scrollLeft) The number of pixels that an element's content is scrolled to the left. -
setScrollTop
public final void setScrollTop(int scrollTop) The number of pixels that an element's content is scrolled to the top. -
setTabIndex
public final void setTabIndex(int tabIndex) The index that represents the element's position in the tabbing order.- See Also:
-
setTitle
The element's advisory title.
-