public class Element extends Node
Modifier and Type | Field and Description |
---|---|
static String |
DRAGGABLE_AUTO
Constant returned from
getDraggable() . |
static String |
DRAGGABLE_FALSE
Constant returned from
getDraggable() . |
static String |
DRAGGABLE_TRUE
Constant returned from
getDraggable() . |
DOCUMENT_NODE, ELEMENT_NODE, TEXT_NODE
Modifier | Constructor and Description |
---|---|
protected |
Element() |
Modifier and Type | Method and Description |
---|---|
boolean |
addClassName(String className)
Adds a name to this element's class property.
|
static Element |
as(JavaScriptObject o)
|
static Element |
as(Node node)
|
void |
blur()
Removes keyboard focus from this element.
|
void |
dispatchEvent(NativeEvent evt)
Dispatched the given event with this element as its target.
|
void |
focus()
Gives keyboard focus to this element.
|
int |
getAbsoluteBottom()
Gets an element's absolute bottom coordinate in the document's coordinate
system.
|
int |
getAbsoluteLeft()
Gets an element's absolute left coordinate in the document's coordinate
system.
|
int |
getAbsoluteRight()
Gets an element's absolute right coordinate in the document's coordinate
system.
|
int |
getAbsoluteTop()
Gets an element's absolute top coordinate in the document's coordinate
system.
|
String |
getAttribute(String name)
Retrieves an attribute value by name.
|
String |
getClassName()
The class attribute of the element.
|
int |
getClientHeight()
Returns the inner height of an element in pixels, including padding but not
the horizontal scrollbar height, border, or margin.
|
int |
getClientWidth()
Returns the inner width of an element in pixels, including padding but not
the vertical scrollbar width, border, or margin.
|
String |
getDir()
Specifies the base direction of directionally neutral text and the
directionality of tables.
|
String |
getDraggable()
Returns the draggable attribute of this element.
|
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.
|
Element |
getFirstChildElement()
The first child of element this element.
|
String |
getId()
The element's identifier.
|
String |
getInnerHTML()
All of the markup and content within a given element.
|
String |
getInnerText()
The text between the start and end tags of the object.
|
String |
getLang()
Language code defined in RFC 1766.
|
Element |
getNextSiblingElement()
The element immediately following this element.
|
int |
getOffsetHeight()
The height of an element relative to the layout.
|
int |
getOffsetLeft()
The number of pixels that the upper left corner of the current element is
offset to the left within the offsetParent node.
|
Element |
getOffsetParent()
Returns a reference to the object which is the closest (nearest in the
containment hierarchy) positioned containing element.
|
int |
getOffsetTop()
The number of pixels that the upper top corner of the current element is
offset to the top within the offsetParent node.
|
int |
getOffsetWidth()
The width of an element relative to the layout.
|
Element |
getPreviousSiblingElement()
The element immediately preceding this element.
|
boolean |
getPropertyBoolean(String name)
Gets a boolean property from this element.
|
double |
getPropertyDouble(String name)
Gets a double property from this element.
|
int |
getPropertyInt(String name)
Gets an integer property from this element.
|
JavaScriptObject |
getPropertyJSO(String name)
Gets a JSO property from this element.
|
Object |
getPropertyObject(String name)
Gets an object property from this element.
|
String |
getPropertyString(String name)
Gets a property from this element.
|
int |
getScrollHeight()
The height of the scroll view of an element.
|
int |
getScrollLeft()
The number of pixels that an element's content is scrolled from the left.
|
int |
getScrollTop()
The number of pixels that an element's content is scrolled from the top.
|
int |
getScrollWidth()
The width of the scroll view of an element.
|
String |
getString()
Gets a string representation of this element (as outer HTML).
|
Style |
getStyle()
Gets this element's
Style object. |
int |
getTabIndex()
The index that represents the element's position in the tabbing order.
|
String |
getTagName()
Gets the element's full tag name, including the namespace-prefix if
present.
|
String |
getTitle()
The element's advisory title.
|
boolean |
hasAttribute(String name)
Determines whether an element has an attribute with a given name.
|
boolean |
hasClassName(String className)
Checks if this element's class property contains specified class name.
|
boolean |
hasTagName(String tagName)
Determines whether this element has the given tag name.
|
static boolean |
is(JavaScriptObject o)
Determines whether the given
JavaScriptObject can be cast to an
Element . |
static boolean |
is(Node node)
|
void |
removeAttribute(String name)
Removes an attribute by name.
|
boolean |
removeClassName(String className)
Removes a name from this element's class property.
|
void |
replaceClassName(String oldClassName,
String newClassName)
Replace one class name with another.
|
void |
scrollIntoView()
Scrolls this element into view.
|
void |
setAttribute(String name,
String value)
Adds a new attribute.
|
void |
setClassName(String className)
The class attribute of the element.
|
void |
setDir(String dir)
Specifies the base direction of directionally neutral text and the
directionality of tables.
|
void |
setDraggable(String draggable)
|
void |
setId(String id)
The element's identifier.
|
void |
setInnerHTML(String html)
All of the markup and content within a given element.
|
void |
setInnerSafeHtml(SafeHtml html)
All of the markup and content within a given element.
|
void |
setInnerText(String text)
The text between the start and end tags of the object.
|
void |
setLang(String lang)
Language code defined in RFC 1766.
|
void |
setPropertyBoolean(String name,
boolean value)
Sets a boolean property on this element.
|
void |
setPropertyDouble(String name,
double value)
Sets a double property on this element.
|
void |
setPropertyInt(String name,
int value)
Sets an integer property on this element.
|
void |
setPropertyJSO(String name,
JavaScriptObject value)
Sets a JSO property on this element.
|
void |
setPropertyObject(String name,
Object value)
Sets an object property on this element.
|
void |
setPropertyString(String name,
String value)
Sets a property on this element.
|
void |
setScrollLeft(int scrollLeft)
The number of pixels that an element's content is scrolled to the left.
|
void |
setScrollTop(int scrollTop)
The number of pixels that an element's content is scrolled to the top.
|
void |
setTabIndex(int tabIndex)
The index that represents the element's position in the tabbing order.
|
void |
setTitle(String title)
The element's advisory title.
|
void |
toggleClassName(String className)
Add the class name if it doesn't exist or removes it if does.
|
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, setNodeValue
cast, createArray, createArray, createFunction, createObject, equals, hashCode, toSource, toString
public static final String DRAGGABLE_AUTO
getDraggable()
.public static final String DRAGGABLE_FALSE
getDraggable()
.public static final String DRAGGABLE_TRUE
getDraggable()
.public static Element as(JavaScriptObject o)
public static boolean is(JavaScriptObject o)
JavaScriptObject
can be cast to an
Element
. A null
object will cause this method to
return false
.public static boolean is(Node node)
public final boolean addClassName(String className)
className
- the class name to be addedtrue
if this element did not already have the specified class namesetClassName(String)
public final void blur()
public final void dispatchEvent(NativeEvent evt)
uncaught exception handler
as usual.evt
- the event to be dispatchedpublic final void focus()
public final int getAbsoluteBottom()
public final int getAbsoluteLeft()
public final int getAbsoluteRight()
public final int getAbsoluteTop()
public final String getAttribute(String name)
Element
and its specific subclasses to retrieve attributes and
properties.name
- The name of the attribute to retrievepublic final String getClassName()
public final int getClientHeight()
public final int getClientWidth()
public final String getDir()
public final String getDraggable()
DRAGGABLE_AUTO
, DRAGGABLE_FALSE
, or
DRAGGABLE_TRUE
public final NodeList<Element> getElementsByTagName(String name)
name
- The name of the tag to match on. The special value "*" matches
all tagspublic final Element getFirstChildElement()
public final String getId()
public final String getInnerHTML()
public final String getInnerText()
public final String getLang()
public final Element getNextSiblingElement()
public final int getOffsetHeight()
public final int getOffsetLeft()
public final Element getOffsetParent()
public final int getOffsetTop()
public final int getOffsetWidth()
public final Element getPreviousSiblingElement()
public final boolean getPropertyBoolean(String name)
name
- the name of the property to be retrievedpublic final double getPropertyDouble(String name)
name
- the name of the property to be retrievedpublic final int getPropertyInt(String name)
name
- the name of the property to be retrievedpublic final JavaScriptObject getPropertyJSO(String name)
name
- the name of the property to be retrievedpublic final Object getPropertyObject(String name)
name
- the name of the property to be retrievedpublic final String getPropertyString(String name)
name
- the name of the property to be retrievedpublic final int getScrollHeight()
public final int getScrollLeft()
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()
public final int getScrollWidth()
public final String getString()
JavaScriptObject.toString()
because it is final in
JavaScriptObject
.public final int getTabIndex()
public final String getTagName()
public final String getTitle()
public final boolean hasAttribute(String 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).
name
- the name of the attributetrue
if this element has the specified attributepublic final boolean hasClassName(String className)
className
- the class name to be addedtrue
if this element has the specified class namepublic final boolean hasTagName(String tagName)
tagName
- the tag name, including namespace-prefix (if present)true
if the element has the given tag namepublic final void removeAttribute(String name)
public final boolean removeClassName(String className)
className
- the class name to be removedtrue
if this element had the specified class namesetClassName(String)
public final void toggleClassName(String className)
className
- the class name to be toggledpublic final void replaceClassName(String oldClassName, String newClassName)
oldClassName
- the class name to be replacednewClassName
- the class name to replace itpublic final void scrollIntoView()
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)
name
- The name of the attribute to create or altervalue
- Value to set in string formpublic final void setClassName(String className)
public final void setDir(String dir)
public final void setDraggable(String draggable)
draggable
- a String constantspublic final void setId(String id)
public final void setInnerHTML(String html)
public final void setInnerSafeHtml(SafeHtml html)
public final void setInnerText(String text)
public final void setLang(String lang)
public final void setPropertyBoolean(String name, boolean value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyDouble(String name, double value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyInt(String name, int value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyJSO(String name, JavaScriptObject value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyObject(String name, Object value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setPropertyString(String name, String value)
name
- the name of the property to be setvalue
- the new property valuepublic final void setScrollLeft(int scrollLeft)
public final void setScrollTop(int scrollTop)
public final void setTabIndex(int tabIndex)
public final void setTitle(String title)
Copyright © 2018. All rights reserved.